title: Fatal error: Call to a member function prepare() on a non-object in C:\xampp\htdocs\cms\include\article.php on line 8
body: <p>i am getting this error and was wondering how to fix it?
  it is when i am trying to add my articles to the feed.
          
  
  <pre><code>class Article {
      public function fetch_all() {
          global $pdo;
  
  
          $query = $pdo-&gt;prepare("SELECT * FROM articles ORDER BY `article_id` DESC");
          $query-&gt;execute();
  
          return $query-&gt;fetchAll();
      }
  
      public function fetch_data($article_id) {
          global $pdo;
  
          $query = $pdo-&gt;prepare("SELECT * FROM articles WHERE article_id = ?");
          $query-&gt;bindValue(1, $article_id);
          $query-&gt;execute();
  
          return $query-&gt;fetch();
      }
  }
  
      ?&gt;
  </code></pre>