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