未定义函数 mysqli_stmt_init() php 错误

undefined function mysqli_stmt_init() php error

我刚开始使用 php mysqli 准备好的语句。无论我尝试什么,我总是收到此错误消息。

Fatal error: Call to undefined function mysqli_stmt_init() in...(etc)

我已经关闭了我的数据库 link 在我的代码下面,它没有显示在这里。这是我的代码:

$link = mysqli_connect($mysql_host, $mysql_user, $mysql_password, $mysql_database);
if (mysqli_connect_errno()) {
    echo 'We\'re having problems connecting right now. Please try again later.';
    exit();
}
$email_query = mysqli_stmt_init($link);
if(mysqli_stmt_prepare($email_query, "SELECT * FROM users WHERE email=?")){
mysqli_stmt_bind_param($email_query, "s", $email);
mysqli_stmt_execute($email_query);
mysqli_stmt_store_result($email_query);
$exists_email = mysqli_stmt_num_rows($email_query);

mysqli_stmt_close($email_query);

error中的行号对应代码中的init行

您不需要 mysqli_stmt_init()。直接发布你准备好的声明。

if(mysqli_prepare($link, "SELECT * FROM users WHERE email=?")){
    mysqli_stmt_bind_param($email_query, "s", $email);
    mysqli_stmt_execute($email_query);
    mysqli_stmt_store_result($email_query);
    $exists_email = mysqli_stmt_num_rows($email_query);
    mysqli_stmt_close($email_query);
}