Page 1 of 1

mysql query error, probably simple!

Posted: Sun Sep 04, 2011 7:20 pm
by mattichu
the following code:

Code: Select all

mysql_query("INSERT INTO photocomment 
(from,comment,photo) VALUES('$me','$_POST[photocomment]','$_POST[photoname]') ")
Presents the following error:

Code: Select all

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 'from,comment,photo) VALUES('matt covell','maybe?','1314041884-180674_10150395951' at line 2
I have been scratching my head for a while now and have no idea why. As we can see from the error the variables are being passed correctly so I thought it was a simple syntax error but still can figure it out >.<

Re: mysql query error, probably simple!

Posted: Sun Sep 04, 2011 8:05 pm
by Christopher
FROM is a reserved word, you might want to try: INSERT INTO photocomment (`from`,comment,photo) VALUES

Re: mysql query error, probably simple!

Posted: Sun Sep 04, 2011 8:16 pm
by mattichu
Genius! many thanks thats fixed the problem!

^.^