Jump to content

Can't use get_result(), mysqlnd is enabled


Erik_Fischer

Recommended Posts

I just moved all of my website files and databases over to a webhost and I've run into the following error when trying to run one of my pages:

Call to undefined method mysqli_stmt::get_result()

I saw this problem before and it had something to do with the mysqlnd driver not being installed. So I contacted the web host and they said that both mysqli and mysqlnd were installed by using the following PHP:

<?php
    if (extension_loaded('mysqlnd'))
        echo 'extension mysqlnd is loaded'; // WORKED

    if (extension_loaded('mysqli'))
        echo 'extension mysqli is loaded'; // WORKED
?>

And here's the PHP I'm trying to run:

 <?php
    $cxn = mysqli_connect("localhost", "my_username", "my_password", "my_database") or die ("Couldn't connect to the server. Please try again.");
      
    $id = 0;
    
    $stmt = $cxn->prepare('SELECT value FROM test WHERE id = ?');
    $stmt->bind_param('i', $id);
    $stmt->execute();
    $result = $stmt->get_result();
    
    echo $result->num_rows;  
?>

Please help!

Link to comment
https://forums.phpfreaks.com/topic/285910-cant-use-get_result-mysqlnd-is-enabled/
Share on other sites

just because the mysqlnd driver is present, doesn't mean php was built to use it, there's a configure switch to get mysqli to use the mysqlnd driver (required with php5.3, built in with php5.4+.) to test if you can use the fetch_all statement -

if(function_exists('mysqli_fetch_all'))

edit: here's a dynamic way of using the most efficient retrieval method that is available in your php installation - http://forums.phpfreaks.com/topic/282959-odd-behaviour-on-webhost-server/?do=findComment&comment=1453950

just because the mysqlnd driver is present, doesn't mean php was built to use it, there's a configure switch to get mysqli to use the mysqlnd driver (required with php5.3, built in with php5.4+.) to test if you can use the fetch_all statement -

if(function_exists('mysqli_fetch_all'))

edit: here's a dynamic way of using the most efficient retrieval method that is available in your php installation - http://forums.phpfreaks.com/topic/282959-odd-behaviour-on-webhost-server/?do=findComment&comment=1453950

 

I ran the fetch_all statement and it came back as false. What should I do to get mysqlnd working now that we know this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.