I have all my script working good except these two functions which are meant to simply query a database. I have checked all variables. Tested both functions flow but no luck. Both queries are returning false. Here is the relevant two functions:
function check_attempts($uid) {
global $conn;
$stmt = mysqli_query($conn, "SELECT attempted, time FROM user_attempts WHERE uid = '$uid'");
if(mysqli_num_rows($stmt) >= 5) {
$stmt_2 = mysqli_query("UPDATE users SET locked = '1'");
if($stmt_2) {
return false;
}
}
else {
return true;
}
}
function update_attempt($uid) {
global $conn;
$now = time();
$stmt = mysqli_query($conn, "INSERT INTO user_attempts(attempted, time, uid) VALUES ('1', '$now', '$uid')");
if($stmt) {
return false;
}
else {
echo "Error in Query";
}
}
I have queried the database manually and both of them worked nicely. I don't think that I am doing anything wrong.