mysql query error, probably simple!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mattichu
Forum Newbie
Posts: 5
Joined: Fri Sep 02, 2011 8:00 pm

mysql query error, probably simple!

Post 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 >.<
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: mysql query error, probably simple!

Post by Christopher »

FROM is a reserved word, you might want to try: INSERT INTO photocomment (`from`,comment,photo) VALUES
(#10850)
mattichu
Forum Newbie
Posts: 5
Joined: Fri Sep 02, 2011 8:00 pm

Re: mysql query error, probably simple!

Post by mattichu »

Genius! many thanks thats fixed the problem!

^.^
Post Reply