'' 附近的 SQL 查询错误 [英] SQL Query Error Near ''
问题描述
UPDATE ".$tablename." SET stock=%s WHERE itemname=".$itemname."
SQL 查询抛出此错误:
SQL Query throwing this error:
您的 SQL 语法有错误;检查手册对应于您的 MySQL 服务器版本以使用正确的语法靠近第 1 行的 ''
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 '' at line 1
无法找到它在谈论什么,因为它只给我 '' 而不是查询中的任何文本.谢谢!
Can't find what it is talking about as it only gives me '' and not any text in the query. Thanks!
推荐答案
上面的字符串拼接看起来真的很乱!我会去做一些简单的事情:
The string concatenation above looks really messy! I would go for something simple:
<代码>$sql = "更新 $tablename SET stock='$stock' WHERE itemname='$itemname'";
如果这不起作用,您应该调试以下值:$tablename, $stock
和 $itemname
If this doesn't work, you should debug the values of : $tablename, $stock
and $itemname
ps.我已经给尼克 +1 了 :)
ps. I've already given +1 to Nick :)
这篇关于'' 附近的 SQL 查询错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!