Page 1 of 1

Cannot Figure Out INSERT Query Error

Posted: Wed Sep 02, 2009 9:21 am
by zunebuggy
I cannot figure out why my INSERT query has an error.

Here is my table schema:
  • text_field1 text
    text_field2 text
    text_field3 text
    text_field4 text
    created_date datetime
    bool1 tinyint(1)
    num_of_days int(11)
    bool2 tinyint(1)
    bool3 tinyint(1)
    bool4 tinyint(1)
    name_field1 varchar(25)
    long_msg1 longtext
Here is my INSERT query

Code: Select all

 
mysql_query("INSERT INTO msgtbl (text_field1, text_field2, text_field3, text_field4, created_date, bool1, num_of_days, bool2, bool3, bool4, name_field1, long_msg1')
VALUES ('$text_val1', '$text_val2', '$text_val3', '$text_val4', CURDATE(), '0', '7', '1', '1', '0', '$name_val1', '$my_msg')") or die(mysql_error());
 
NOTE:With the CURDATE() I am attemping to populate the datetime type field with a current date and time stamp. The 5 values after that are not variables but literal values. The rest with the preceedig $ are of course php variables.

And here is the error it is returning:
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 '') VALUES ('4883032953', 'Anonymous', 'Anonymous', 'No Subject', CURDATE(), '0'' at line 1
What do I have malformed in my sql query?

Thank you.
-Joe

Re: Cannot Figure Out INSERT Query Error

Posted: Wed Sep 02, 2009 10:55 am
by Benjamin
You have a ' after long_msg1

Re: Cannot Figure Out INSERT Query Error

Posted: Wed Sep 02, 2009 11:07 am
by zunebuggy
Thank you very much! That is all it was.... Something that small caused all my gray hairs last night :)