开发者

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

开发者 https://www.devze.com 2023-01-25 01:24 出处:网络
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 th
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

精彩评论

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