Prepared statement failing

I have a prepared statement that fails and I really cannot find the reason why:

$stmt = $connection->prepare('SELECT password 
                                   FROM users
                                   WHERE email=(?)')
  $stmt->bind_param('s',$sessionmail);
          $stmt->execute();
          $stmt->bind_result($password);
          $stmt->fetch();

$sessionmail has my mail in it(I cannot disclose it for obvious reasons).

Furthermore the SQL statement above runs OK in the console…with the password being retrieved from the db table.

Do you see anything wrong with the code above?

Nevermind I found what the problem was.

Though you solved the problem on your own, can you update with what the problem was and how you solved it? I see at least one issue with the code alone, but being not as familiar with mysqli (I assume is what you’re using), there may be more than one issue that I don’t recognize.

Thanks.

the whole prepared statement is inside an IF statement(not shown above)…in this case I had forgotten the curly braces that go after the IF statement.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.