title: PDO test if connected
body: <p>I can't find an answer to this anywhere. Maybe its really simple</p>
  
  <p>I have my mysql PDO connection like this:</p>
  
  <pre><code>try{
  $DBH = new PDO("mysql:host=$db_hostname;dbname=$db_database", $db_username, $db_password);
  $DBH-&gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );  
  }
  catch (PDOException $e){
  echo $e-&gt;getMessage();
  exit;
  }
  </code></pre>
  
  <p>i want to just test if the connection worked, ie. if the password, username, databasename &amp; hostname were spelled correctly.</p>
  
  <p>the try, throw just seems to pick up fundamental errors, like if the driver is spelt wrong. it doesnt throw an error if say the password is wrong.</p>
  
  <p>thanks</p>