title: PDO error handling and storing errors in database
body: <p>How would I go about getting PDO statements to generate a safe error message? I don't want the user to see the error message. I want them to get directed to a page that says a clean message, "Whoops something unexpected happened!". I would also like to log the errors in a database to review and catch errors others are generating.</p>
  
  <p>I'm using PHP and MySQL.</p>
  
  <p>I found that when you make your connection you can set your error handling like this.</p>
  
  <pre><code>$dbh = new PDO($dsn, $user, $password);
  $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  </code></pre>
  
  <p>Anyone do anything like this before?</p>