开发者

SQL syntax error with MySQL and PHP. 'option FROM poll_maker_options WHERE poll_id = 3' [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a spe开发者_StackOverflow中文版cific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago.

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 ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜