可能重复:
how escape quotes when inserting into database in PHPSQL语法错误
为什么这个sql查询产生这个错误?
$sql_categorybooknumber = "SELECT SUM(items_counter)
FROM categories
WHERE category_id = '$categoryid' ";
误差
You have an error in your SQL syntax
'SELECT SUM(items_counter) FROM categories WHERE category_id = '426' WHER' at line 1
类别ID在这里
elseif ( preg_match($regexComputerProgramingkeyword1, $itemtitle)
or preg_match ($regexComputerProgramingkeyword2, $itemtitle)
or preg_match($regexComputerProgramingkeyword1, $productsgroupmessage)
or preg_match($regexComputerProgramingkeyword2, $productsgroupmessage))
{
$categoryid = '426';
}
你可以发布你的其他代码吗?至少你定义了'$ categoryid'的部分以及你查询数据库的地方。 – andrewsi
而您查询数据库的代码?它看起来像是将一个额外的WHERE连接到查询的末尾。 – andrewsi