gpt4 book ai didi

PHP fatal error : Call to undefined function mysqli_stmt_get_result()

转载 作者:可可西里 更新时间:2023-11-01 07:24:44 24 4
gpt4 key购买 nike

我不断收到错误 PHP fatal error :调用未定义函数 mysqli_stmt_get_result()。我使用的是 PHP 5.6 版,并在我的托管服务提供商 c 面板中启用了扩展名 mysqlind,但我不明白为什么我仍然收到此错误。我研究并发现每次我需要启用 mysqli nd 才能使用 mysqli_stmt_get_result。任何人都可以协助/教导我做错了什么。谢谢。

注册.PHP:

<?php
session_start();
include '../dbh.php';

$respond = array(
'status' => true,
'message' => 'There was an error',
'redirect',
'errors'
);

if (isset($_POST['submit'])) {

$first = $_POST['first'];
$last = $_POST['last'];
$email = $_POST['email'];
$pwd = $_POST['pwd'];

$errorEmpty = false;
$errorEmail = false;


if (empty($first) || empty($last) || empty($email) || empty($pwd)) {

$respond['errors'][] = "Please fill out all fields!";
$respond['errorEmpty'] = true;

} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$respond['errors'][] = "Please enter a valid email address!";
$respond['errorEmail'] = true;

} else {
$sql = "SELECT email FROM user WHERE email= ? ";
$stmt = mysqli_prepare($conn, $sql);
mysqli_stmt_bind_param($stmt, 's', $email);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt); //This is where I getting my error
$num_rows = mysqli_num_rows($result);
if ($num_rows > 0) {
$respond['errors'][] = "That email address already exists!";
$respond['errorEmail'] = true;
}

else {
$encryptpwd = password_hash($pwd, PASSWORD_DEFAULT);
$sql = "INSERT INTO user (first, last, email, pwd) VALUES (?,?,?,?)";
$stmt = mysqli_prepare($conn, $sql);
mysqli_stmt_bind_param($stmt, 'ssss', $first, $last, $email, $password_hash);

if (mysqli_stmt_execute($stmt)) {

$userID = mysqli_insert_id($conn);
$status = 1;
$sql2 = "INSERT INTO profileImg (email, status) VALUES(?,?)";
$stmt2 = mysqli_prepare($conn, $sql2);
mysqli_stmt_bind_param($stmt2, 'si', $email);
mysqli_stmt_execute($stmt);

$_SESSION['id'] = $userID;

$respond['redirect'] = "../profile.php?id=$userID";
}
}
}
}
echo json_encode($respond);
?>

最佳答案

为了防止其他人在启用 mysqlnd native 驱动程序时试图找出为什么这不起作用的尖叫数小时。这是因为您需要确保启用两个 native 驱动器。如果您希望使用此功能,则需要在您的服务器上启用 mysqlnd 和 nd_mysqli。

否则仅启用 mysqlnd native 驱动程序不包括 mysqli_stmt_get_result 函数,因为这显然位于 nd_mysqli native 驱动程序中。不幸的是,大多数文档只讨论 mysqlnd native 驱动程序。

启用两个 native 驱动程序后,此功能将按照文档说明工作。

哦,在我的托管服务器上,您需要禁用/取消选中 mysqli 才能启用 nd_mysqli。

Screenshot of cpanel

关于PHP fatal error : Call to undefined function mysqli_stmt_get_result(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45001819/

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