The following statement works perfectly fine under PHP 5.2:
$db = new mysqli($db_host, $db_user, $db_pass, $database);
$sql = $db->prepare('SELECT id, field1, field2, field3 FROM people WHERE email = ? AND pass=?');
$user = strtolower($_POST['user']);
$pass = md5($_POST['pass']);
$sql -> bind_param('ss', $user ,$pass);
$sql -> execute();
$sql -> bind_result($id, $field1, $field2, $field3);
if ($sql -> fetch()) {
...
}
However, after upgrading to PHP 5.4 the fetch()
fails and gives the following error:
Attempt to read a row while there is no result set associated with the statement
I couldn't find any hints that something has changed regarding the functions I use and the way I use them. I have seen that there was a change for bind_param
using arrays in 5.3, but as I'm not using arrays here, I don't think that I'm affected by this change.