13
$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?

Dharman
  • 30,962
  • 25
  • 85
  • 135
piku
  • 285
  • 3
  • 6
  • 9

2 Answers2

34
$num_rows = $result->num_rows;
  • 6
    +1 - For the right answer, but it helps to give more info. http://www.php.net/manual/en/mysqli-stmt.num-rows.php, as num_rows is part of the mysqli extension and mysql_num_rows is part of a different extension. – James Black Aug 08 '10 at 14:19
2

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

GDP
  • 8,109
  • 6
  • 45
  • 82
manoj
  • 21
  • 1