I am trying to keep a register of how many times users fail when they try to get login in my blog, I am using prepared statements for every query and I don't know why but I have the next error when I try to save the failed login intent: Call to a member function bind_param() on boolean in C:\xampp\htdocs\Blog\users\login.php on line 70
Here is the code where the problem is...
// code when the login is correct...
} else {
// incorrect password.
// so we save this failed intent
//we make a query to get the actual user's intent
$num_attempts = $conexion->prepare("SELECT session_attemps FROM usuarios WHERE id = ? LIMIT 1");
$num_attempts->bind_param('i', $user_id);
$num_attempts->execute();
$num_attempts->bind_result($attempts);
$num_attempts->fetch();
$attempt= $attempts+1;
//and then we insert that value plus one (the actual failed intent)
$add_attempt=$conexion->prepare("INSERT INTO usuarios(session_attemps) VALUES (?) WHERE id = $user_id");
$add_attempt->bind_param('i', $attempt);
$login_error_message="login data is incorrect";
echo json_encode(array('success' => false, 'text' => $login_error_message));
return false;
}
Line 70 corresponds to: $add_attempt->bind_param('i', $user_id);
but when I test the query (with normal or default values) by mysql console it says that the error is near WHERE id=...