MySQL 和 PHP 的 SQL 语法错误。 '来自 poll_maker_options 的选项,其中 poll_id = 3'

发布于 2024-10-02 22:50:37 字数 335 浏览 0 评论 0原文

我有这个查询:

SELECT votes, option 
  FROM poll_maker_options 
 WHERE poll_id = " . $row['poll_id']

我认为没有任何问题,但出现错误:

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行“option FROM poll_maker_options WHERE poll_id = 3”附近使用的正确语法

感谢您的帮助。我希望我不会像昨天一样盲目,当时我无法发现打字错误。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一刻暧昧 2024-10-09 22:50:37

“option”是MySQL中的保留字,所以更改字段名称,或者在使用它的所有查询中用反引号将其括起来:

SELECT votes, `option` FROM ...

"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 ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文