gpt4 book ai didi

php - 调用未定义的方法 mysqli_stmt::get_result

转载 作者:行者123 更新时间:2023-11-29 03:25:40 25 4
gpt4 key购买 nike

这是我的代码:

include 'conn.php';
$conn = new Connection();
$query = 'SELECT EmailVerified, Blocked FROM users WHERE Email = ? AND SLA = ? AND `Password` = ?';
$stmt = $conn->mysqli->prepare($query);
$stmt->bind_param('sss', $_POST['EmailID'], $_POST['SLA'], $_POST['Password']);
$stmt->execute();
$result = $stmt->get_result();

我在最后一行得到的错误是:Call to undefined method mysqli_stmt::get_result()

这是 conn.php 的代码:

define('SERVER', 'localhost');
define('USER', 'root');
define('PASS', 'xxxx');
define('DB', 'xxxx');
class Connection{
/**
* @var Resource
*/
var $mysqli = null;

function __construct(){
try{
if(!$this->mysqli){
$this->mysqli = new MySQLi(SERVER, USER, PASS, DB);
if(!$this->mysqli)
throw new Exception('Could not create connection using MySQLi', 'NO_CONNECTION');
}
}
catch(Exception $ex){
echo "ERROR: ".$e->getMessage();
}
}
}

如果我写这行:

if(!stmt) echo 'Statement prepared'; else echo 'Statement NOT prepared';

它打印'Statement NOT prepared'。如果我直接在 IDE 中运行查询替换 ?带有值的标记,它工作正常。请注意 $conn 对象在项目的其他查询中工作正常。

请帮忙......

最佳答案

请阅读此方法的用户说明:

http://php.net/manual/en/mysqli-stmt.get-result.php

它需要 mysqlnd 驱动程序...如果它没有安装在您的网站空间上,您将不得不使用 bind_result() & fetch() !

关于php - 调用未定义的方法 mysqli_stmt::get_result,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36639785/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com