调用未定义的方法mysqli_stmt :: get_result()和mysqlnd已安装 [英] Call to undefined method mysqli_stmt::get_result() AND mysqlnd installed

查看:56
本文介绍了调用未定义的方法mysqli_stmt :: get_result()和mysqlnd已安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所示,在运行PHP版本5.4的共享托管服务器上,我有mysqlnd可用.当我尝试调用mysqli get_result()函数时,出现此错误.

As the title suggests, I have mysqlnd available on my shared hosting server running PHP version 5.4. When I attempt to call the mysqli get_result() function, I get this error.

我已经与托管服务提供商多次交谈,最近他们告诉我尝试运行

I have spoken several times with the hosting provider, and most recently they told me to try running

# /opt/ntphp/php54/bin/php -i | grep -i mysqlnd

我跳到ssh并运行了以下命令:

I hopped on ssh and ran this command which gave this:

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 $

所以,这在我看来就像我期望的那样.

So, that appears to me as I would expect.

我在另一个建议运行的论坛帖子中找到了另一段PHP代码:

I found another piece of PHP code on another forum post that suggests running:

$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;

我做到了,得到了结果:

I did this and got the result:

(已弃用)MySQL已安装,并且新的(改进的)MySQL已安装.该服务器使用libmysqlclient作为驱动程序.

(Deprecated) MySQL is installed and the new (improved) MySQL is installed. This server is using libmysqlclient as the driver.

我正在用Arvixe运行我的主机,他们有一篇博客文章,基本上说运行PHP 5.4,这将起作用".对我来说很明显,他们认为该功能应该运行,但是却给了我一个致命的错误.

I'm running my hosting with Arvixe, and they had a blog post that basically said "Run PHP 5.4 and this will work". It's clear to me that they think this function should run, but it's giving me a fatal error instead.

旁注-代码在我的本地计算机上运行良好,并且我对get_result()的调用只会出错.

Side note - the code runs perfectly on my local machine, and I only get an error with the call to get_result().

这是PHP的设置方式:

Here is how the PHP is set up:

$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

推荐答案

对于任何想知道这是怎么回事并使用Arvixe的人.这是我从员工那里收到的回复.

For anybody wondering what's going on with this, and using Arvixe. Here is the response I received from the staff.

这是关于MySQLND的一些混淆,这是由一个旧版本引起的 平台及其将与我的员工交流的东西.

This is some confusion around MySQLND which was caused by an old platform and its something I'll be communicating to my staff.

我们过去运行的系统允许我们拥有单独的PHP 安装后,此时5.4和5.5都运行了MysqlND.这 我们拥有的新PHP系统会在一致的状态下运行所有​​PHP安装 配置,因此我们的PHP 5.3安装(基本安装)不是 使用MySQLND也不安装5.4或5.5.

We used to run a system which allowed us to have individual PHP installs and at that point 5.4 and 5.5 both had MysqlND running. The new PHP system we have in place runs all PHP installs on a consistent config and therefore with our PHP 5.3 install (the base install) not using MySQLND nor does our 5.4 or 5.5 install.

由于PHP 5.6将MySQLND作为 默认值.

This will be reviewed in future as PHP 5.6 is going to have MySQLND as a default.

当前,我们唯一支持MySQLND的方法是通过VPS/专用 服务器.

Currently the only way we can support MySQLND is via a VPS / dedicated server.

因此,如果您使用的是Arvixe而不是VPS,那么使用超级通用和推荐的约定从数据库中检索数据就很不走运.使用大量不同的方法可以解决此问题.它们对我的项目来说不可行,或者我无法使它们工作,但是对于较小的查询,似乎使用$ stmt-> bind_result()是最受欢迎的方法之一. http://php.net/manual/en/mysqli-stmt.bind -result.php

So, if you're on Arvixe and not a VPS, you're out of luck for using a super common and recommended convention for retrieving data from your database. There are workarounds for this using a ton of different methods. They either aren't feasible for my project or I couldn't get them to work, but for smaller queries it seems that using $stmt->bind_result() is one of the more popular methods. http://php.net/manual/en/mysqli-stmt.bind-result.php

对我来说,我将把业务带回GoDaddy.我花了10多个小时尝试解决此问题,但没有提供任何解决方案,只是如果您不满意,我们将提供60天的退款保证."

For me, I'm taking my business back to GoDaddy. I spent over 10 hours trying to get a solution for this with no resolution offered except "We have a 60 day money back guarantee if you're not satisfied."

感谢大家对此提供帮助.令人沮丧的是,我在此过程中以及从这些委员会中学到了很多东西……通常是这样.

Thanks everyone for helping out with this. Frustrating as it's been, I learned a lot in the process and from these boards... As is usually the case.

这篇关于调用未定义的方法mysqli_stmt :: get_result()和mysqlnd已安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆