0
我已经看到与此类似的非常类似的错误问题,但是我似乎仍然无法解决问题,所以很抱歉如果这可能是重复的。致命错误:调用非对象的成员函数bind_param()
反正这里是代码:
/**
* 8.This method is used to get no of pending bets.
*/
public function noOfPendingBets($userId){
$res = array();
$stmt = $this->conn->prepare("select bet_id from user_bets where user_id=?");
echo $userId;
$stmt->bind_param("s", $userId);
$stmt->execute();
$stmt->bind_result($bet_id);
$num_row=0;
$stmt->fetch();
echo "bet_id:".$bet_id."<br>";
$sumBets=$this->abc($bet_id);
$num_row = $num_row+$sumBets;
$stmt->close();
return $num_row;
}
public function abc($bet_id)
{
$stmt = $this->conn->prepare("select u.user_id from user u inner join bets b on u.user_id=b.creator_id and b.bet_id=? and b.correct_option is null");
$stmt->bind_param("i", $bet_id);
$stmt->execute();
$stmt->store_result();
echo "no of rows:".$stmt->num_rows;
return $stmt->num_rows;
$stmt->close();
}
$ stmt-> bind_param(“s”,$ userId);这应该是“我”我相信,因为id是整数不是字符串 – 2014-09-12 12:09:31
你可能需要添加关闭类,所以我们可以看到你是如何设置属性conn – 2014-09-12 12:09:40
尝试$ stmt-> bind_param(“我”,$ userId) ; ...仍然不能正常工作 – AbhiCool 2014-09-12 12:13:47