正如标题所示,我在运行 PHP 5.4 版的共享托管服务器上有可用的 mysqlnd。当我尝试调用 mysqli get_result() 函数时,出现此错误。
我已经与托管提供商多次交谈,最近他们告诉我尝试运行
# /opt/ntphp/php54/bin/php -i | grep -i mysqlnd
我跳上 ssh 并运行这个命令,结果如下:
mysqlnd
mysqlnd => enabled
Version => mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $
Loaded plugins => mysqlnd,example,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password
mysqlnd statistics =>
Client API version => mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $
所以,这在我看来正如我所期望的那样。
我在另一个论坛帖子上发现了另一段 PHP 代码,建议运行:
$hasMySQL = false; $hasMySQLi = false; $withMySQLnd = false; $sentence = '';
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_get_client_stats')) {
$withMySQLnd = true;
$sentence.= "This server is using MySQLnd as the driver."; } else
$sentence.= "This server is using libmysqlclient as the driver.";
echo $sentence;
我这样做并得到了结果:
(已弃用)MySQL 已安装,新的(改进的)MySQL 已安装。该服务器使用 libmysqlclient 作为驱动程序。
我正在使用 Arvixe 运行我的托管,他们有一篇博客文章基本上说“运行 PHP 5.4,这将起作用”。我很清楚他们认为这个函数应该运行,但它却给了我一个致命错误。
旁注 - 代码在我的本地计算机上完美运行,并且我只在调用 get_result() 时收到错误。
EDITED:
PHP 的设置方式如下:
$stmt = $con->prepare("SELECT * FROM User_Details WHERE LCASE(username) = LCASE(?) LIMIT 1");
$stmt->bind_param("s", $username);
$stmt->execute();
$result = $stmt->get_result(); // This line throws the ugly error