警告:mysql_num_rows()期望参数1是资源,

时间:2010-08-08 14:06:35

标签: php mysql

  

可能重复:
  mysql_fetch_array() expects parameter 1 to be resource, boolean given in select

代码 -

$q="SELECT * FROM tbl_quevote WHERE que_id = '".$qid."' and voteby='".$uid."'";

$result = $mysqli->query($q) or die(mysqli_error($mysqli));
$num_rows = mysql_num_rows($result);

echo $num_rows;

错误: 警告:mysql_num_rows()要求参数1为资源,第13行的C:\ xampp \ htdocs \ shizin \ voting.php中给出的对象
how to check result is empty?

2 个答案:

答案 0 :(得分:32)

$num_rows = $result->num_rows;

答案 1 :(得分:2)

int mysql_num_rows ( resource $result ) 从结果集中检索行数。此命令仅对返回实际结果集的SELECTSHOW等语句有效。要检索受INSERT, UPDATE, REPLACE or DELETE查询影响的行数,请使用mysql_affected_rows()