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

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (171)

我一直收到错误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);
    ?>
提问于
用户回答回答于

你有正确安装的mysqlnd驱动程序吗?根据手册中的评论:

如果你没有安装/加载任何mysqlnd,则在尝试调用“mysqli_stmt_get_result()”时将获得未定义的引用。

用户回答回答于

扫码关注云+社区

领取腾讯云代金券