这个函数在我的测试环境中工作得很好。但当我在我的网络主机上尝试它时,返回此错误。Fatal error: Call to undefined method mysqli_stmt::get_result()
我知道您需要mysqlnd驱动程序来完成此任务。但在版本5.4.x的Source中会自动支持它。但我的主机上甚至安装了更新版本的PHP。所以我不明白为什么它不能工作。
Test environment:
PHP: 5.4.12
MySQL: 5.6.12
Webhost (doesnt work):
PHP: 5.4.37
MySQL: 5.5.42-cll我该如何解决这个问题?是否需要手动安装mysqlnd驱动程序?或者和MySQL版本有什么关系。
编辑:我在我的网站主机上放了一个测试文件,get_result()功能似乎不可用。
<?php
$hasMySQL = false;
$hasMySQLi = false;
$withMySQLnd = false;
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_fetch_all')) {
$withMySQLnd = true;
$sentence.= "This server is using MySQLnd as the driver.";
} else
$sentence.= "This server is using libmysqlclient as the driver.";
echo $sentence . "<br>";
$db = new PDO('mysql:host=localhost;dbname=xxx', 'xxx', 'xxx');
if (strpos($db->getAttribute(PDO::ATTR_CLIENT_VERSION), 'mysqlnd') !== false) {
echo 'PDO MySQLnd enabled!'. "<br>";
}
else {
echo 'Not enabled'. "<br>";
}
if (function_exists('get_result')){
echo "get result() works". "<br>";
}
else {
echo "nope result() doesnt work". "<br>";
}
phpinfo();
$arr = get_defined_functions();
print_r($arr);你可以在这里看到结果:Test page on my host
我要联系我的主机提供商。但我想知道是否有其他解决方案/变通办法
编辑:所以我的主机提供商不能帮助我。他们不想只为我改变mysqli服务器。所以我换成了PDO而不是MySQLi,这有点糟糕,因为我必须重写很多:(.
发布于 2015-03-12 05:05:50
检查你的php.ini。您需要启用mysqli dll
extension=php_mysqli.dllhttps://stackoverflow.com/questions/28997292
复制相似问题