title: mysql_connect to PDO connection
body: <p>I've been trying to convert a mysql_connect connection into a PDO connection with no success, here is what I have:</p>
  
  <pre><code>$host = 'localhost';
          $user = 'root';
          $pwd = '';
          $db = 'jdlferreira';
          $connection = mysql_connect($host, $user, $pwd) or die("Could not connect");
          mysql_select_db($db) or die("Could not select database");
  
          $query = "SELECT COUNT(*) FROM blog";
          $result = mysql_query($query) or die(mysql_error());
          $num_rows = mysql_fetch_row($result);
  
          $pages = new Paginator;
          $pages-&gt;items_total = $num_rows[0];
          $pages-&gt;mid_range = 9; // Number of pages to display. Must be odd and &gt; 3
          $pages-&gt;paginate();
  
          $query = "SELECT id, title, resume, date
              FROM blog
              ORDER BY date DESC $pages-&gt;limit";
          $result = mysql_query($query) or die(mysql_error());
  
  
          while ($row = mysql_fetch_row($result)) {
  //do stuff
  }
  </code></pre>
  
  <p>And what I tried to do with PDO:</p>
  
  <pre><code>include_once 'inc/db.inc.php';
          $db = new PDO(DB_INFO, DB_USER, DB_PASS);
          mysql_select_db("jdlferreira") or die("Could not select database");
  
          $query = "SELECT COUNT(*) FROM blog";
          $result = mysql_query($query) or die(mysql_error());
          $num_rows = mysql_fetch_row($result);
  
          $pages = new Paginator;
          $pages-&gt;items_total = $num_rows[0];
          $pages-&gt;mid_range = 9; // Number of pages to display. Must be odd and &gt; 3
          $pages-&gt;paginate();
  
          $query = "SELECT id, title, resume, date
              FROM blog
              ORDER BY date DESC $pages-&gt;limit";
          $result = mysql_query($query) or die(mysql_error());
  
  
          while ($row = mysql_fetch_row($result)) {
  //do stuff
  }
  </code></pre>
  
  <p>I'm getting a "Could not select database" error, I don't really care for the 'or die' cases, I would just like to make this connection functional on PDO, any help would be great.</p>