在非对象中调用成员函数bind_param()

时间:2016-08-17 09:53:41

标签: php android binding

我在标题中看到很多问题。但他们的解决方案都无法解决我的问题。这是我的问题;

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;
}

}

这个工作正常但是,

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;
}

}

这个给了我关于第46行的非对象错误的bind_param()。只有它们之间的区别是,其中一个使用1个参数而另一个使用2个参数。

1 个答案:

答案 0 :(得分:1)

$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");

WHERE

之前删除text_id < ?