可能重复:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select
以下是我的简单搜索查询但是显示
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in
C:\xampp\htdocs\project\p\answer.php on line 52
No Result Found
52行:
$numserach = mysql_num_rows($search_sql);
Php代码:
$search_sql = mysql_query("SELECT * FROM questions WHERE q_name LIKE %$search%");
$numserach = mysql_num_rows($search_sql);
if($numserach == 1)
{
echo $numserach. "Result found";
}
else
{
echo "No Result Found";
}
感谢:)
答案 0 :(得分:5)
您的查询中存在错误,请使用单引号将LIKE
查询部分括起来:
"SELECT * FROM questions WHERE q_name LIKE '%$search%'"
由于您遇到错误,$search_sql
没有解析为sql结果资源,mysql_num_rows
因此显示错误。