title: Why is my PDO not working?
body: <p>I am starting to use PDO and I successfully connected to MySQL using PDO. However, when I try to SELECT stuff from my DB, nothing happens. Nothing is echoed. (even though I have records in that table, and the column username exists) No error in my PHP log.</p>
  
  <p>I am using MAMP and all PDO components seem to be working in phpinfo() (since I was able to connect to db in the first place)</p>
  
  <p>Please let me know what could have gone wrong. Thanks a lot</p>
  
  <pre><code>    &lt;?php
      try 
      {
          $connection = new PDO('mysql:host=localhost;dbname:my_db','my_username',
                                'xxxxxxx');   
  
  
              $stmt=$connection-&gt;prepare("SELECT * FROM users");
              $stmt-&gt;execute();
  
              while ($row=$stmt-&gt;fetch(PDO::FETCH_OBJ)){
  
                  echo $row-&gt;username;
              }
  
      }
  
      catch(Exception $e)
      {
          echo "There was an error connecting to the database";
      }
  
      ?&gt;
  </code></pre>