Bagwell
Bagwell

Reputation: 2226

Can't use get_result(), mysqlnd is enabled

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!

Upvotes: 2

Views: 882

Answers (1)

Your Common Sense
Your Common Sense

Reputation: 157871

mysqlnd is not actually an extension, but a library used to by extensions. So your host have to build php with options like --with-mysqli=mysqlnd

Upvotes: 2

Related Questions