I have the below snippet of code. When I run the whole program, it fails at this section with the error Fatal error: Call to a member function fetch() on a non-object in <filename> on line 26
. I'm really not sure what I should do to fix the problem. If it matters, I ran the SQL query against my database and it returns exactly what it should.
if(isset($_POST['submit'])) {
$query = 'SELECT email FROM users WHERE email=:email';
$query_params = array(':email' => $_POST['email']);
try {
$stmt = $conn->prepare($query);
$result = $stmt->execute($query_params);
} catch(PDOException $ex) {
echo $ex->getMessage();
}
$row = $result->fetch(); //fails on this line
if(empty($results)) {
$passset = 1;
}
}