title: Fatal error: Uncaught Error: Call to a member function fetch() on boolean in #0 {main} thrown in on line 7
body: <p>I got fatal error</p>
  
  <blockquote>
    <p>Fatal error: Uncaught Error: Call to a member function fetch() on boolean in C:\xampp\htdocs\sonu\PDO\test.php:7 Stack trace: #0 {main} thrown in C:\xampp\htdocs\sonu\PDO\test.php on line 7    </p>
  </blockquote>
  
  <pre><code>$db = new PDO('mysql:host=localhost;root', 'test', '');
  
  $query = $db-&gt;query("SELECT * FROM sonu");
  
  while($row = $query-&gt;fetch())
  {
      print_r($row);
  }
  </code></pre>