Я видел много вопросов с этим заголовком. Но ни одно из их решений не могло решить мою проблему. Вот моя проблема;
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;
}
}
этот дает мне bind_param () для необъектной ошибки в строке 46. Единственное различие между ними состоит в том, что один из них использует 1 параметр, а другой использует 2 параметра.
$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 < ?
Других решений пока нет …