对非对象的成员函数bind_param()的调用(尽管进行了研究仍无法解决)

问题描述 投票:4回答:3
$stmt = $mysqli->prepare('select Un from member where Lock = ? and Activated = ?');
$stmt -> bind_param("ss", 'N', 'Y');//This line gave the error
$stmt -> execute();
$stmt->store_result();//apply to prepare statement
$numRows = $stmt->num_rows;

if ($numRows > 0)//if have result
 while ($row = $stmt->fetch())

我上面的代码给了我“在非对象上调用成员函数bind_param()”]错误。我真的不明白为什么我得到这个错误。我有正确的列名。

我是mysqli的新手,想学习如何调试这种错误。

  1. 我的prepare语句或bind_param()有什么问题?
  2. 请教我如何调试此类错误

$ stmt = $ mysqli-> prepare('从其中Lock =?和Activated =?的成员中选择Un。); $ stmt-> bind_param(“ ss”,'N','Y'); //此行给出了错误$ stmt-> execute(); $ stmt-> store_result(); ...

php mysqli
3个回答
14
投票

Call to a member function bind_param() on a non-object表示您试图调用$stmt on



0
投票

[$mysqli->error()返回语句对象,如果发生错误,则返回$stmt->bind_param("ss", 'N', 'Y');//This line gave the error

© www.soinside.com 2019 - 2024. All rights reserved.