我收到以下错误请帮助
警告:mysql_num_rows()要求参数1为资源,布尔值在第16行的D:\ hosting \ 10102937 \ html \ search.php中给出
警告:mysql_num_rows()要求参数1为资源,布尔值在第23行的D:\ hosting \ 10102937 \ html \ search.php中给出
警告:mysql_num_rows()要求参数1为资源,布尔值在第25行的D:\ hosting \ 10102937 \ html \ search.php中给出
这是我的PHP代码
include("connection.php");
$type = $_POST['type'];
$address = $_POST['address'];
$bedrooms = $_POST['bedrooms'];
$min = $_POST['price'];
$max = $_POST['price'];
//$sql ="SELECT * FROM subscribers2 WHERE type = '%$type%' AND address = '%$address%' AND bedrooms = '%$bedrooms%' AND min as '%$min%' AND max as '%$max%' ";
$rs_result = mysql_query ($sql);
$num_rows = mysql_num_rows($rs_result);
$query = mysql_query("SELECT * FROM subscribers2 WHERE type = '%$type%' AND address = '%$address%' AND bedrooms = '%$bedrooms%' AND min as '%$price%' AND max as '%$price%' ");
$rs_result = mysql_query ($sql);
$num_rows = mysql_num_rows($rs_result);
$query = mysql_query("SELECT * FROM subscribers2 WHERE type LIKE '%$type%' AND address LIKE '%$address%' AND bedrooms LIKE '%$bedrooms%' AND min as '%$price%' AND max as '%$price%' ");
$number=mysql_num_rows($query);
?>
答案 0 :(得分:0)
当您将查询字符串注释掉时,它看起来像您的查询$sql
。
但这只是3个mysql错误中的一个。
您将使用mysql_error
as documented here找出错误。
您还应该查看SQL注入,您的参数将直接通过POST传递到数据库级别,这会使您的服务器数据库全开。