Reputation: 213
When the below code is executed, num_rows always returns 0 even if the SQL statement should be fetching one result. I have confirmed that there is a token to select at the associated user_email, so what gives?
$stmt = $db->prepare("SELECT token FROM users WHERE user_email = ?");
$stmt->bind_param("s", $_POST['email']);
confirmQuery($stmt);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows < 1) {
echo(displayMessage("Token did not exist! Exiting program.","danger"));
exit;
}
Upvotes: 0
Views: 305
Reputation: 213
Solved it myself. The problem was that I was sending via the get method, not post, so the $_POST['email'] was a mistake. The query must have been looking for rows where email was empty, but no rows like that exist, thus the 0 num rows.
Upvotes: 1