2 Replies - 176 Views - Last Post: 07 March 2019 - 01:35 AM Rate Topic: -----

#1 arunasl   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-March 19

mysqli_num_rows() and mysqli_fetch_array() expects parameter 1

Posted 07 March 2019 - 12:08 AM

I'm getting following PHP errors after executing a PHP script.

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /test.php on line 28


Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /test.php on line 29


I tried to solve this by referring articles related to
mysqli_num_rows()
and
mysqli_fetch_array()
but still unable to identify the problem. I'm not an expert coder.

Here is my code from Line 21 to Line 40:

$from_name = "";
$from_id ="";
if(isset($_GET['id']) && $_GET['id'] != "")
{
	$receiver_id = $_GET['id'];
	$tmp=mysqli_query($conn,"SELECT id,fname,lname FROM ".C_MYSQL_MEMBERS." WHERE id=".$_GET['id']." AND status >= '7'");

    $count=mysqli_num_rows($tmp);
    $row=mysqli_fetch_array($tmp);

	$from_name=$row['fname'].' '.$row['lname'];
	$from_id = $row['id'];
	if($count == '0') {
	 $error = 1;
	  }
}
else
{
	$error = 1;
}


Please help me to fix these two errors

Is This A Good Question/Topic? 0
  • +

Replies To: mysqli_num_rows() and mysqli_fetch_array() expects parameter 1

#2 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4227
  • View blog
  • Posts: 13,400
  • Joined: 08-June 10

Re: mysqli_num_rows() and mysqli_fetch_array() expects parameter 1

Posted 07 March 2019 - 01:11 AM

Your query fails. It's as simple as that (since like many other functions mysqli_query() returns false on failure).
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6792
  • View blog
  • Posts: 28,050
  • Joined: 12-December 12

Re: mysqli_num_rows() and mysqli_fetch_array() expects parameter 1

Posted 07 March 2019 - 01:35 AM

Presumably status is a number so you don't need to surround 7 with quotes.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1