好吧我一直在爲我的網站創建一個搜索功能,目前爲止一切都很順利我找到了一個真正有幫助的YouTube教程,並且我已將所有代碼放入搜索中.php文件。Php搜索函數返回錯誤
但我得到這些錯誤也許有人可以解釋他們對我和可能的幫助
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/content/34/9587634/html/MyDomain.Com/search.php on line 21
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/content/34/9587634/html/MyDomain.Com/search.php on line 25
這裏是使用的代碼IM。我曾嘗試搜索和不能似乎找到了問題
<html>
<?php
$k = $_GET['k'];
$terms = explode(" ", $k);
$query = "SELECT * FROM content WHERE ";
foreach ($terms as $each){
$i++;
if ($i == 1)
$query .= "content LIKE '%$each%' ";
else
$query .= "OR content LIKE '%$each%' ";
}
include('config.php');
$query = mysql_query($query);
$numrows = mysql_num_rows($query);
while ($row = mysql_fetch_assoc($query)) {
$FirstName = $row['FirstName'];
}
?>
</html>
所有的幫助感激謝謝
您的腳本似乎容易受到[SQL注入](http://en.wikipedia.org/wiki/SQL_injection)的影響。 – Gumbo