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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3434601/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 09:45:35  来源:igfitidea点击:

Warning: mysql_num_rows() expects parameter 1 to be resource,

phpmysql

提问by piku

code-

代码-

$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;

Error:Warning: mysql_num_rows() expects parameter 1 to be resource, object given in C:\xampp\htdocs\shizin\voting.php on line 13
how to check result is empty?

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

回答by

$num_rows = $result->num_rows;

回答by manoj

int mysql_num_rows ( resource $result )Retrieves the number of rows from a result set. This command is only valid for statements like SELECTor SHOWthat return an actual result set. To retrieve the number of rows affected by a INSERT, UPDATE, REPLACE or DELETEquery, use mysql_affected_rows().

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