好的,我今天一直在为我的网站创建搜索功能,到目前为止一切顺利,我找到了一个真正有用的 youtube 教程,我已将所有代码放入 search.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
这是我使用的代码。我已经尝试搜索,但似乎无法找到问题
<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>
非常感谢所有帮助谢谢