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!

Edited by Erik_Fischer
Link to comment
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

Edited by mac_gyver
Link to comment
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

 

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.