PHP can't split these two fetching types, I am trying to build a secured login script... If I remove //Login checker part, the code runs good, when I remove //Security part the other code runs well also, but when I try to run it with both together it shows me this error:
Fatal error: Uncaught Error: Call to a member function fetch_all() on bool in xxxFilenamexxx.php://Number of line points to fetch_all() row
stack trace:
#0 {main}
thrown in xxxFilenamexxx.php//Same line number
And here is my code:
//Login checker
$loginTrySql = "CALL tryLogUserIn('$typedUsername', '$typedPassword', '".$_SERVER['REMOTE_ADDR']."');";
$loginTryResult = $conn->query($loginTrySql);
if ($loginTryResult->num_rows == 1) {
$data["statusi"] = 1;
$data["tries"] = 0;
//data to fetch for log in
} else {
//Security part
$data["statusi"] = 2;
$checkUserSql = "CALL securityCheck('$typedUsername', '$typedPassword', '".$_SERVER['REMOTE_ADDR']."', @tries_number);";
$conn->query($checkUserSql);
$checkUserSql = "SELECT @tries_number AS tries";
$checkUserResult = $conn->query($checkUserSql);
$securityRow = $checkUserResult->fetch_all(MYSQLI_ASSOC);
$data["tries"] = $securityRow[0]['tries'];
}
echo json_encode($data);