Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6153777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:08:57+00:00 2026-05-23T20:08:57+00:00

I have this weird problem when trying to INSERT a row into my mysql

  • 0

I have this weird problem when trying to INSERT a row into my mysql database.

This is the idea. A range of exercise is listed and you can add a quantity and check the days you want to add this exercise to (Sun, Mon, Tue, Wed, Thu, Fri, Sat) and that adds it to your diary.

This is my code.

$addDiary = array();
$addTimestamp = array();
$addDiary[] = '('.$current_user->id.', '.$_POST['exid_'.$i].', '.$_POST['qty_'.$i].', '.$calories_mod.', '.implode('.', $addTimestamp).')';             
$queryAddDiary = mysql_query("INSERT INTO LHNZ_FT_DIARY (USER_ID, EXERCISE_ID, TIME, CALORIES, TIMESTAMPS) VALUES ".implode(',', $addDiary));

I have echoed out the addDiary array and the addTimestamp array and it looks fine to me.

$addTimestamp: 1311206400.1311292800.1311379200

$addDiary: (2, 1, 1, 678, 1311206400.1311292800.1311379200)

That query works beautifully if my $addTimestamp array has a length of 1 or 2. However when the length is greater than 2, it chucks this error.

You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ‘.1311379200)’ at line 1

Now. This error is shown if I use ‘.’ or ‘:’ as my implode for $addTimestamp. If I use a letter, or ‘_’ it chucks this error.

Unknown column ‘1311206400_1311292800_1311379200’ in ‘field list’

Any ideas how I can use $addTimestamp with a length greater than 2 (meaning I may do that exercise three days a week… this is where it errors).

Thanks,

  • leighton
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:08:57+00:00Added an answer on May 23, 2026 at 8:08 pm

    String values in MySQL queries must be enclosed in single quotes.

    Instead of:

    $addDiary[] = '('.$current_user->id.', '.$_POST['exid_'.$i].', '.$_POST['qty_'.$i].', '.$calories_mod.', '.implode('.', $addTimestamp).')'; 
    

    Do:

    $addDiary[] = '('.$current_user->id.', '.$_POST['exid_'.$i].', '.$_POST['qty_'.$i].', '.$calories_mod.", '".implode('.', $addTimestamp)."')"; 
    

    Although I strongly suggest that you also pass every value through mysql_real_escape_string() before gluing it to sql query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a weird problem I have started having recently. My team is developing
This is a really weird problem that I have been having. When I download
This is kind of a weird problem, but I have to create a search
I have this idea for a free backup application. The largest problem I need
We have this really weird problem in a Web Application when using ActiveRecord 2.0
Good day, I have this weird problem: This following statement works Query q =
This could be weird, Have you ever come across a blog which you wanted
This is pretty weird. I have my Profiler open and it obviously shows that
This one is weird, I have a page that consists of a html table
Sounds like a weird question, but say I have something like this: $.post( /myajax.php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.