一尘不染

PHP致命错误:调用未定义函数mysqli_stmt_get_result()

mysql

我不断收到错误PHP致命错误:调用未定义函数mysqli_stmt_get_result()。我正在使用PHP版本5.6,并在主机提供商c面板中启用了扩展mysqlind,但我不知道为什么仍然出现此错误。我进行了研究,发现每次需要启用mysqli
nd才能使用mysqli_stmt_get_result。任何人都可以协助/教导我在做什么错。谢谢。

SIGNUP.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);
    ?>

阅读 235

收藏
2020-05-17

共1个答案

一尘不染

您是否已正确安装mysqlnd驱动程序?根据手册中的评论:

如果您没有安装或加载mysqlnd,则在尝试调用“ mysqli_stmt_get_result()”时会得到未定义的引用。

另外,这里这里都对此问题进行了讨论。

最后,这是一个论坛,讨论有关将驱动程序与cpanel一起使用的信息,您可能会觉得有用。

2020-05-17