Fatal error: Call to undefined method mysqli_stmt::get_result()

I have the following, which I built while testing on my WAMP server…but I have a major problem. When I moved it online, I get the following error: Fatal error: Call to undefined method mysqli_stmt::get_result()
I researched it and it says I need mysqlnd to get that to work? I’m not even sure what that means, really, but seems I can’t get it? My server uses PHP 5.4…and I read that mysqlnd needs to be compiled? Again, not sure what that means and if I can even do that on my server…

[php]
if($stmt = $db->prepare($q)) {
$stmt->bind_param(‘i’,$id);
$stmt->execute();
$result = $stmt->get_result();
$stmt->store_result();
while ($row = $result->fetch_assoc()) {

foreach ($row as $k => $v) {
}
}
[/php]

I am so lost as what to do. I can’t seem to find anther way to write this! Any help? I need it to be an assoc array so I can fetch it by the key and value.

Apparently I posted too soon, because I found my solution!! :slight_smile:

(I swear, I spent 3 hours on this…and found nothing…and then all of a sudden!)

But here’s what I did:

[php]if($stmt = $db->prepare($q)) {
$stmt->bind_param(‘i’,$id);
$stmt->execute();
$meta = $stmt->result_metadata();
while ($field = $meta->fetch_field())
{
$params[] = &$row[$field->name];
}

call_user_func_array(array($stmt, ‘bind_result’), $params);

while ($stmtchx->fetch()) {

foreach($row as $k => $v)
{
$c[$k] = $v;
echo $k." - ".$v;
}
}[/php]

Looking over your code, I could tell you were close. Sometimes just taking a break or posting for help gives inspiration in itself for the solution. :smiley: Anyways, glad you have it working. Now test and test some more. :wink:

Sometimes just taking a break

[member=57087]Strider64[/member] , for sure on taking a break. Many a time I was completely stumped on something, stepped away for a minute and the answer just popped in my head without even trying.

Sponsor our Newsletter | Privacy Policy | Terms of Service