Ömer Faruk KISIK Ömer Faruk KISIK - 3 months ago 20
Android Question

Call to a member function bind_param() on a non-object in

I saw many questions with that headline. But none of their solutions could solve my problem.Here is my problem;

public function getLiveWallPost(){
$acik="smthng";
$stmt = $this->conn->prepare("SELECT text_id,type,header,body,date FROM text WHERE type = ? order by text_id desc limit 20");
$stmt->bind_param("s", $acik);
if ($stmt->execute()) {
$stmt->bind_result($text_id,$type,$header,$body,$date);
while ($stmt->fetch()) {
$post['text_id']=$text_id
$post['type']=$type;
$post['header']=$header;
$post['body']=$body;
$post['date']=$date;
$postsArray[]=$post;
}
return $postsArray;
}


}

this one is working correctly but ,

public function getLiveWallPostNext20($id){
$acik="smthng";
$stmt = $this->conn->prepare("SELECT text_id,type,header,body,date FROM text WHERE type = ? and WHERE text_id < ? order by text_id desc limit 20");
$stmt->bind_param("si", $acik,$id); //line 46
if ($stmt->execute()) {
$stmt->bind_result($text_id,$type,$header,$body,$date);
while ($stmt->fetch()) {
$post['text_id']=$text_id
$post['type']=$type;
$post['header']=$header;
$post['body']=$body;
$post['date']=$date;
$postsArray[]=$post;
}
return $postsArray;
}


}

this one giving me bind_param() on a non-object error at line 46. Only difference between them is, one of them uses 1 parameter and other one uses 2 parameters.

Answer
$stmt = $this->conn->prepare("SELECT text_id,type,header,body,date FROM text WHERE type = ? and text_id < ? order by text_id desc limit 20");

Remove WHERE before text_id < ?