title: Fatal error: Uncaught Error: Call to a member function fetch_object() on boolean
body: <p>I'm trying to figure out how to fix this error... I've seen other questions that have been closed but none of them have fixed my problem, I get that there's an issue with fetch_object() being boolean but I can't figure out why.</p>
  
  <p>here's the my function:</p>
  
  <pre><code>function getNews($objCon, $page = null) {
      $sql = "SELECT id, headline, description FROM cms_news";
      if ($page) {
          $sql .= "WHERE cms_category_id = $page";
      }
  
      $objectResult = $objCon-&gt;query($sql);
      $news = [];
      while ($row = $objectResult-&gt;fetch_object()) {
          $news[$row-&gt;id] = $row;
      }
      return $news;
  }
  </code></pre>
  
  <p>Thank you!!!</p>