title: "Fatal error: Call to a member function prepare() on a non-object.."
body: <p>Following error occures:</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function prepare() on a non-object</p>
  </blockquote>
  
  <p>The code:</p>
  
  <pre><code>class Guestbook {
  
      public $db;
  
      public function getEntries(){
          $result = false;
          $query = 'SELECT * FROM db ORDER BY id DESC'; 
  
          $stmt = $this-&gt;db-&gt;prepare($query); //error in this line (17)                               
          // ...
      }   
  }       
  </code></pre>