This question already has an answer here:
below is mysql query, the problem is the query only works as long as there is only one php
variable such as
Select * From student where Account = ".$username."
but if I change the code to be as below, I got the error
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given.
What might be the problem here, please help me.
$result = $con->query("SELECT * FROM '.$role.' WHERE Account = '.$username.' AND password = '.$password.' AND IsApproved = '.$approval.'");
if(mysqli_num_rows($result) == 1) {
$_SESSION['username'] = $username;
header('Location: include/test.php');
}
else {
echo "Account is invalid";
}
}
EDIT : PROBLEM SOLVED - Answer by Dhaval Dave
$result = $con->query("SELECT * FROM {$role} WHERE Account = '{$username}' AND password = '{$password}' AND IsApproved = '{$approval}'");
Thanks alot to everyone for helping me all the suggestion, I appreciated what you guys did to me. Thanks alot x1000
</div>