title: Handle database exceptions with php
body: <p>This exception(error) is displayed when i try to delete a user.</p>
  
  <pre><code>Error: the XML response that was returned from the server is invalid.
  Received:
  Cannot delete or update a parent row: a foreign key constraint fails                         
  (`db_almacen`.`perfil_solicitud_material`, CONSTRAINT `perfil_solicitud_material_ibfk_1`
  FOREIGN  KEY (`id_usuario`) REFERENCES `usuario` (`id_usuario`))
  </code></pre>
  
  <p>It is displayed on that way because i have a FOREIGN KEY related to my user's id.
  I would like to display a different message instead of that. How can i do this i checked php exceptions manual but i didn't find an example please help me.
  I am using Mysql and PHP
  My php code </p>
  
  <pre><code>$query = "DELETE FROM unidad_solicitante where id_unid_sol ='$cod';";
  $result = mysql_query($query) or die(mysql_error()); 
  </code></pre>
  
  <p>Thank You</p>