I made a login script in PHP, and the process needs to check whether data from login form is match with data in my table. I use mysqli_num_rows to do that. But it gives zero value. How can I fix this?
I have no idea but I've already tried a method with mysqli_fetch_array and the result is still same.
Edit : Table app_user has id_level, and id_level is a foreign key. Is there could be a problem in the database? But I'm not using id_level in the login process. Or it could be a xampp server error?
include "lib/conn.php";
$data = mysqli_query($conn, "SELECT * FROM app_user WHERE username='$user' AND password='$pass'") or die(mysqli_error($conn));
echo "<pre>".print_r($data, true)."</pre>";
if(mysqli_num_rows($data) == 0){
$_SESSION['error'] = '<strong>ERROR!</strong> username atau password salah.';
//header('Location:login.php');
echo "x";
die();
}
So, I want mysqli_num_rows to give me 1, but the existing output is 0.