2015-05-29 67 views
-1

哪些錯誤與此代碼?:問題與像在PHP的mysqli

SELECT alias FROM Articls 
WHERE (title LIKE '%key%' 
OR sections LIKE '%key%' 
OR description LIKE '%key%' 
OR category LIKE '%key%' 
OR subcategory LIKE '%key%) 
AND MATCH (content) AGAINST ('key') 
GROUP BY alias ORDER BY alias DESC LIMIT 500 

,但我得到了一個錯誤。所以我簡化代碼這樣:

SELECT alias FROM Articls 
WHERE (title LIKE '%key%' 
OR content LIKE '%key%' 
OR sections LIKE '%key%' 
OR description LIKE '%key%' 
OR category LIKE '%key%' 
OR subcategory LIKE '%key%) 
ORDER BY alias DESC LIMIT 500 

但我仍然得到一個錯誤:

Warning: mysqli_fetch_all() expects parameter 1 to be mysqli_result, boolean given in /home/admin/domains/example.com/public_html/lib/core/p.php on line 141 - 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 ''%news%)

+0

此處的語法高亮顯示(顏色編碼)表示缺少引號的位置。你看到了嗎? – showdev

+0

ooo a waldo遊戲!它在子類別LIKE'%key% –

回答

1

您在最後的LIKE語句結尾缺少一個撇號。

SELECT alias FROM Articls 
WHERE (title LIKE '%key%' 
OR content LIKE '%key%' 
OR sections LIKE '%key%' 
OR description LIKE '%key%' 
OR category LIKE '%key%' 
OR subcategory LIKE '%key%') 
ORDER BY alias DESC 
LIMIT 500