-1

How can I fix this error?

$qry = "select id,pwd,username  from users where username='jimmy'";
$res = mysqli_query($conn,$qry);
$row = mysqli_fetch_array($res);
$count = mysqli_num_rows($row); // if uname/pass correct it returns must be 1 row
Dharman
  • 30,962
  • 25
  • 85
  • 135

2 Answers2

3

As the error says the parameter should be a mysqli_result object. So use the returned value from your mysqli_query() call

$res=mysqli_query($conn,$qry);

$count = mysqli_num_rows($res);
//                       ^^^^
$row=mysqli_fetch_array($res);
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
1

this is the problem

$count = mysqli_num_rows($row); 

this should be

$count = mysqli_num_rows($res); 
Alex Odenthal
  • 211
  • 1
  • 11