Jump to content

error with mysqli_num_rows()


stickcult

Recommended Posts

Hello, I'm new here (just signed up to post this), but I have an error that I can't figure out, and is really bothering me..

 

The code causing the error is

 

$query = "SELECT * FROM quizsite_login WHERE username={$user} and password={$pass}";
$result = mysqli_query($link,$query);
$numrows = mysqli_num_rows($result);

 

and the error is

 

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in ........ on line 20

 

Any help at all would be appreciated!

Link to comment
https://forums.phpfreaks.com/topic/121106-error-with-mysqli_num_rows/
Share on other sites

Your query failed.  You need to check if the query failed with something like:

 

$result = mysqli_query($link, $query) OR die(mysqli_error($link));

 

By the way, your query failed because you had no ' ' around your username or password in the query, making MySQL think it was a column name and not a string.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.