未定义的函数mysqli_stmt_init()php错误 [英] undefined function mysqli_stmt_init() php error

查看:66
本文介绍了未定义的函数mysqli_stmt_init()php错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用php mysqli准备语句的新手.无论我尝试什么,我总是会收到此错误消息.

I'm new to using php mysqli prepared statements. No matter what I try I always get this error message.

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

我在下面的代码中进一步关闭了数据库链接,此处未显示.这是我的代码:

I have close my database link further below in my code, it isn't show here. Here is my code:

$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);

错误中的行号与代码中的init行相对应.

The line number in the error corresponds to the init line in the code.

推荐答案

您不需要mysqli_stmt_init().只需直接发出准备好的声明即可.

You don't need mysqli_stmt_init(). Just issue your prepared statement directly.

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);
}

这篇关于未定义的函数mysqli_stmt_init()php错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆