SQL syntax error with MySQL and PHP. 'option FROM poll_maker_options WHERE poll_id = 3' [closed]
I have this query:
SELECT votes, option
FROM poll_maker_options
WHERE poll_id = " . $row['poll_id']
I see nothing wrong with that but I get the 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 'option FROM poll_maker_options WHERE poll_id = 3' at line 1
Thank you for any help. I hope I'm not blind like yesterday when I couldn't spot a typo.
"option" is a reserved word in MySQL, so either change the field name, or surround it with backticks in all the queries it's used in:
SELECT votes, `option` FROM ...
精彩评论