0

I am writing some code to fetch data using prepared statements. Below is my code

$statement = $connection->prepare("select * from products where id =?");
$statement->bind_param('d',$id);
$statement->execute();
$result = $statement->get_result();
$product_details = $result->fetch_all();

I am using PHP 5.6.This works fine on my localhost with no error. When I uploaded this file to my Godaddy Host this will gives error:

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

I searched over internet, but not found satisfied results, On stackoverflow I found several question similar to this but not got solution for me. On Godddy host I enabled mysqld extension and also running PHP 5.6 So any help

Dharman
  • 21,838
  • 18
  • 57
  • 107
Abhijit Kumbhar
  • 822
  • 3
  • 17
  • 43

1 Answers1

0

There might be issue with your $statement->execute(). try to run this code in try catch block, may be you find some exception. or run this method with if block.

if($statement){
    $result = $statement->get_result();
} 

or

try{
   $statement = $connection->prepare("select * from products where id =?");
   $statement->bind_param('d',$id);
   $statement->execute();
   if($statement){
     $result = $statement->get_result();
   } 
   $product_details = $result->fetch_all(); 
} catch (Exception $e) {
   echo 'Caught exception: ',  $e->getMessage(), "\n";
}
Chandraveer
  • 161
  • 1
  • 9