gpt4 book ai didi

尝试插入几个值时 PHP/MySQL 语法错误

转载 作者:行者123 更新时间:2023-11-29 08:27:57 25 4
gpt4 key购买 nike

如何修复 PHP/MySQL 中的这一行?服务器返回错误

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 ''id', 'title', 'yes', 'no') VALUES (2,test, 0, 0)' at line 1

对于行

mysql_query("INSERT INTO things('id', 'title', 'yes', 'no') VALUES ($counter,$thing, 0, 0);", $con);

最佳答案

"INSERT INTO things (`id`, `title`, `yes`, `no`) VALUES ($counter,$thing, 0, 0);"

使用刻度线而不是单引号。另外,您没有在那里引用您的字符串。您应该进行适当的 sanitizer 。

您应该切换到 PDO 或 mysqli。 mysql_ 函数已弃用。

关于尝试插入几个值时 PHP/MySQL 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17438075/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com