可能重複:
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