-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
  • 26,923
  • 21
  • 73
  • 125

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
  • 89,708
  • 20
  • 100
  • 143
1

this is the problem

$count = mysqli_num_rows($row); 

this should be

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