title: How to handle error for duplicate entries?
body: <p>I have a PHP form that enters data into my MySQL database. My primary key is one of the user-entered values. When the user enters a value that already exists in the table, the MySQL error &quot;Duplicate entry 'entered value' for key 1&quot; is returned.
  Instead of that error, I would like to alert the user that they need to enter a different value. Just an echoed message or something.</p>
  <p>How to turn a specific MySQL error into a PHP message?</p>