Tsangares Tsangares - 4 months ago 55
SQL Question

mysqli_stmt::get_result() not working

I am running MAMP on windows. php_mysqli.dll is enabled in the php.ini file.

Along with that, in php info it says the mysqlnd is enabled:

phpinfo mysqlind

Here is what my php looks like:

$connection = connect();
if($stmt = $connection->prepare("SELECT * FROM `users` WHERE `email` = '?'")){
$stmt->bind_param("s", $email);
$stmt->execute();
$result = $stmt->get_result();
}


The line
$result = $stmt->get_result()
throws the error
PHP Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::get_result()


Any guesses why
get_result()
is not working?

Any help is much appreciated.

EDIT:
This is different than the questions already asked because all of the solutions refer to mysqlind not being enabled although, in my case it is.

Answer

If you switch to PDO you can use fetchAll instead. PDO is better than mysqli for several reasons, one including the ability to pass in arrays as parameters before execution.