2

I keep getting this error message and I've looked everywhere on what I can do to fix it but I couldn't find anything. Any help will be greatly appreciated.

I'm trying to create a local server database for an android app I'm making on Android Studio so I'm trying to work on the login stuff. But I can't move forward unless I fix this error.

Error: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\wamp64\www\login.php on line 9

Code:

require "conn.php"; // Connection

$user_name = "123";
$user_pass = "123";

$mysql_qry = "select * from employee_data where username like '$user_name' and password like '$user_pass';";

$result = mysqli_query($conn, $mysql_qry);

if (mysqli_num_rows ($result) > 0) {
    echo "Login Successful!";

} else {
    echo "Login Unsucessful!";
}
ra1993
  • 59
  • 1
  • 5
  • Can you please format your code properly? – CUGreen Aug 08 '17 at 04:20
  • Yeah sorry just reformatted it. I'm just super confused by what the error means and what I should exactly do. This is my first time using wamp and there isn't much material out there on how to solve the problem. I was following a tutorial and so was my friend we both followed the same exact video but I keep getting this error. – ra1993 Aug 08 '17 at 04:25
  • You initialised `$user_name` and `$user_pass` to an empty string and then tried to use those in a select query? – RiggsFolly Aug 08 '17 at 06:59
  • The query failed so `$result` is set to FALSE which is not a mysqli::result object! – RiggsFolly Aug 08 '17 at 07:00
  • **PS** its nothing to do with WAMP – RiggsFolly Aug 08 '17 at 07:01
  • Welll I filled the $user_name and $user_pass with account info already in the server but it returns the same error. I created an account with $user_name = "123"; and $user_pass = "123"; but it still returns the same error – ra1993 Aug 08 '17 at 15:28

0 Answers0