2

Researching, looking on stackoverflow, looking through Google, I have found several people with the same problem, and the solution generally is "Available only with mysqlnd."

And so I look around and poked at some code, but as far as I can tell, mysqlnd IS enabled on my server. So that is why I do not believe this is a duplicate.

$id = $stmt->get_result();

That line of code, for whatever reason, seems to be causing a hiccup in my application that works perfectly on my local XAMPP server. I am figuring it's some sort of issue with my public server configuration, but I cannot figure out what.

PHP is throwing this error:

[18-Mar-2014 15:39:27 America/Denver] PHP Fatal error:  
Call to undefined method mysqli_stmt::get_result() in 
/home/PATH/PAGE.php on line 47

Again, my code works fine on my local server. Here's some snapshots of my phpinfo()...

MySQLi Seems to Exist...

MySQLnd Seems to Exist...

And just for good measure, my PHP version is 5.4.22. And, finally, running php -i | grep mysqlnd in system console gives me mysqlnd => enabled.

So... What's up? What am I missing? Thankyou for your consideration. I hope this can help others along the way, too. More code (as requested)...

$mysqli = new mysqli('localhost', 'usr', 'pass', 'table');
$chkid = "SELECT * FROM `students` WHERE student_id = ? LIMIT 1";
if ($mysqli->connect_error) { //We'll catch an error or two here.
  die("{CNCT}");
} 
$arrays = json_decode($_POST['data'], true); //Here, we take the JSON string and create PHP arrays
for ($x=0; $x<=((count($arrays))-1); $x++) { //We count the array
  $stmt = $mysqli->prepare($chkid);
  $inputz = ($arrays[$x]['id']);
  $stmt->bind_param("s", $inputz);
  $stmt->execute();
  $id = $stmt->get_result(); //THIS LINE
  $stmt->close();
  $row = $id->fetch_array(MYSQLI_NUM);
}

I do hope I appropriately cut out everything I needed to without screwing up the code. It is working on my local XAMPP server.

smts
  • 3,585
  • 1
  • 16
  • 14
  • I think get_result() doesn't work if you don't have libmysqlnd isntalled. – Nick Beeuwsaert Mar 18 '14 at 22:14
  • What does `var_dump($stmt)` tell you? – tlenss Mar 18 '14 at 22:15
  • You need to post more code than simply the line that the error indicates. We need to see how `$stmt` has been initialized. – Sammitch Mar 18 '14 at 22:22
  • tlenss, var_dump($stmt) gives me an object with a bunch of stuff in it. If you need it, I can paste it here. Sammitch, since you requested it, give me a moment I will promptly post more code. Keep in mind my code is working fine on my local server. – smts Mar 18 '14 at 22:27
  • @Sammitch I've added some code to the end of the question. – smts Mar 18 '14 at 22:34

2 Answers2

2

It requires not only mysqlnd presence just by itself, but also mysqli has to be built specifically with mysqlnd support. To do so, PHP has to be built with configuration option

--with-mysqli=mysqlnd

in your phpinfo output, mysqlnd has to be mentioned under Client API library version item in mysqli section:

Good: enter image description here

Not good: enter image description here

I've no idea about XAMPP though, as I always build whole servers manually. It seems you need to look for another version or another distribution.

Jerther
  • 5,558
  • 8
  • 40
  • 59
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
0

After trying many things, I rebuilt Apache (in WHM, using EasyApache) with MySQL (NOT MySQL of the system) and MySQL Improved (MySQLi). Previously I had used a combination of MySQL (of the system) and MySQL Improved. After the build completed, everything was working like magic.

Thanks everyone!

smts
  • 3,585
  • 1
  • 16
  • 14