这个问题在这里已有答案:
我正在编写一些代码来使用预处理语句获取数据。以下是我的代码
$statement = $connection->prepare("select * from products where id =?");
$statement->bind_param('d',$id);
$statement->execute();
$result = $statement->get_result();
$product_details = $result->fetch_all();
我正在使用PHP 5.6
。这在我的localhost
上运行正常,没有错误。当我将此文件上传到Godaddy Host时,会出错:
PHP致命错误:调用未定义的方法mysqli_stmt :: get_result()
我在互联网上搜索,但没有找到满意的结果,在stackoverflow上我发现了几个类似的问题,但没有得到解决方案。在Godddy主持人我启用mysqld
扩展并运行PHP 5.6
所以任何帮助
您的$ statement-> execute()可能存在问题。尝试在try catch块中运行此代码,可能是您发现了一些异常。或使用if块运行此方法。
if($statement){
$result = $statement->get_result();
}
要么
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";
}