Forum Moderators: coopster

Message Too Old, No Replies

You have an error in your SQL syntax

error message when trying to insert

         

blackrhinomarketing

7:22 pm on Sep 27, 2009 (gmt 0)

10+ Year Member



I'm trying to just do an insert and I keep getting an error message:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use

This is the sql I used:


$sql = "INSERT INTO visitTable (custID, desc, date, formula, product1, product2, product3, product4, product5, product6, product7, product8, product9, product10) VALUES ('$clientID', '$desc', '$todaysDate', '$Formula', '$product1', '$product2', '$product3', '$product4', '$product5', '$product6', '$product7', '$product8', '$product9', '$product10')";

this is what the string looks like when I echo it:
INSERT INTO visitTable (desc, date, formula, product1, product2, product3, product4, product5, product6, product7, product8, product9, product10) VALUES ('tewt', '9/27/2009', 'test', '450', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL')

Dinkar

9:25 pm on Sep 27, 2009 (gmt 0)

10+ Year Member



Try

NULL

instead of

'NULL'

eelixduppy

9:49 pm on Sep 27, 2009 (gmt 0)




desc, date,

This is probably the problem. You cannot use reserved words without escaping them. You must escape them for it to work properly...


`desc`, `date`,

Try surround them with the prime character and try again. :)

jd01

1:56 pm on Sep 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Been up too long, can't read, but this part is true:

'".$clientID."' would probably be faster...
[webmasterworld.com...]