gpt4 book ai didi

php - SQL - fatal error : Call to a member function bind_param() on a non-object

转载 作者:太空宇宙 更新时间:2023-11-03 10:48:39 25 4
gpt4 key购买 nike

假设我有这个 PHP 代码:

    $emailCheck = $_POST['emailCheck'];
echo "Checking: " . $emailCheck; // Checking: test@test.net
var_dump($stmt);
$sql = "SELECT id, email FROM members WHERE email=?";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param("s", $emailCheck);
$stmt->execute();
$stmt->bind_result($m_id, $m_email);
$stmt->execute();

和我的数据库:

enter image description here

如您所见,我可以从 PHPMyAdmin 获取它。但是,PHP 页面是另一回事,因为我得到:

Fatal error: Call to a member function bind_param() on a non-object in...

违规行是:

$sql = "SELECT id, email FROM members WHERE email=?";

我做错了什么?

谢谢。

在执行 var_dump($stmt); 后,我得到:

object(mysqli_stmt)[4]
public 'affected_rows' => null
public 'insert_id' => null
public 'num_rows' => null
public 'param_count' => null
public 'field_count' => null
public 'errno' => null
public 'error' => null
public 'error_list' => null
public 'sqlstate' => null
public 'id' => null

编辑:尽管我尽可能地描述了,但我还是被否决了。优雅。

最佳答案

请使用 $mysqli->stat() 确保您的 mysql 连接正常。

关于php - SQL - fatal error : Call to a member function bind_param() on a non-object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27577704/

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