Call undefined method mysqli_stmt :: get_result () and mysqlnd is set

As the name implies, I have mysqlnd available on my shared hosting server with PHP version 5.4. When I try to call the mysqli get_result () function, I get this error.

I spoke with the hosting provider several times, and most recently they told me to try to run

# /opt/ntphp/php54/bin/php -i | grep -i mysqlnd 

I hopped on ssh and ran this command that gave this:

 mysqlnd mysqlnd => enabled Version => mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $ Loaded plugins => mysqlnd,example,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password mysqlnd statistics => Client API version => mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $ 

So it seems to me as I expected.

I found another piece of PHP code in another forum that suggests running:

 $hasMySQL = false; $hasMySQLi = false; $withMySQLnd = false; $sentence = ''; if (function_exists('mysql_connect')) { $hasMySQL = true; $sentence.= "(Deprecated) MySQL <b>is installed</b> "; } else $sentence.= "(Deprecated) MySQL <b>is not</b> installed "; if (function_exists('mysqli_connect')) { $hasMySQLi = true; $sentence.= "and the new (improved) MySQL <b>is installed</b>. "; } else $sentence.= "and the new (improved) MySQL <b>is not installed</b>. "; if (function_exists('mysqli_get_client_stats')) { $withMySQLnd = true; $sentence.= "This server is using MySQLnd as the driver."; } else $sentence.= "This server is using libmysqlclient as the driver."; echo $sentence; 

I did this and got the result:

(Deprecated) MySQL is installed and the new (improved) MySQL is installed. This server uses libmysqlclient as a driver.

I start my hosting with Arvixe, and they have a blog post that says, "Run PHP 5.4 and it will work." It’s clear to me that they think this function should work, but it gives me a fatal error.

Side note - the code works fine on my local machine, and I get an error with the call to get_result ().

EDITED:

This is how PHP is configured:

 $stmt = $con->prepare("SELECT * FROM User_Details WHERE LCASE(username) = LCASE(?) LIMIT 1"); $stmt->bind_param("s", $username); $stmt->execute(); $result = $stmt->get_result(); // This line throws the ugly error 
+5
source share
3 answers

For someone, it’s interesting what happens with this, and using Arvix. Here is the answer I received from the staff.

This is some confusion around MySQLND that was caused by the old platform and something that I will tell my staff.

We used a system that allowed us to have separate PHP and at that moment both modes of MysqlND in 5.4 and 5.5. the new PHP system in which we work runs all PHP installations on a serial config and, therefore, with our installation of PHP 5.3 (basic installation) and not using MySQLND, and do not install our versions 5.4 or 5.5.

This will be considered in the future as PHP 5.6 will have MySQLND as the default.

Currently, the only way to support MySQLND is to use a VPS / server.

So, if you are on Arvixe and not VPS, you are out of luck if you use a super general and recommended convention to extract data from your database. To do this, workarounds are used using tons of different methods. They are either impossible for my project, or I could not get them to work, but for small queries it seems that using $ stmt-> bind_result () is one of the most popular methods. http://php.net/manual/en/mysqli-stmt.bind-result.php

For me, I will get my business back to GoDaddy. I spent more than 10 hours trying to find a solution for this without permission, with the exception of "We have a 60-day money back guarantee if you are not satisfied."

Thanks to everyone for helping with this. Be that as it may, I learned a lot in this process and from these boards ... As usual.

+4
source

When you ran the code that tested the PHP environment, was it through a web server? I am asking about this because it looks like you have not configured your web server to use PHP 5.4 (which supposedly has the version of mysqli you are using).

You can refer to this article from Arvixe.

Interestingly, the function causing the problem is available with PHP 5.3.

You can also try a simple script to view the environment from the Internet.

 <?php phpinfo(); 

Remove it from the internet and check out a couple of things

  • PHP version 5.4
  • mysqlnd

Personally, I'm not sure what mysqlnd is required to provide the get_results function (but you need to dig deeper for this).

Another test you can do to make sure that Arvixe PHP 5.4 actually provides a function of interest is the CLI test, which you know has mysqlnd

 /opt/ntphp/php54/bin/php -r 'echo method_exists("mysqli_stmt", "get_result") . PHP_EOL;' 

If this spills out 1 , you will almost certainly need to follow this guide, which I contacted earlier, so that your web server environment works with PHP 5.4.

+1
source

Remove the existing php version and install the new php version 5.5 or later and verify by running $ php -v on the root terminal

+1
source

All Articles