Giving user-friendly error messages for database errors
Posted: Wed Feb 18, 2004 9:40 am
Hello,
I am using MySQL and PHP and I want to give a user-friendly error message when somebody tries to enter a duplicate record.
So instead of Duplicate entry ' ' for key 2, I want it to say something like ' this record has already been entered'.
Is there a way of writing user-friendly messages by seeing what kind of error occured or is the only way to do a select query on the database to see if the record exists. I don't want to do that if there's a better, less costly way of doing it.
Thanks
Hannah
I am using MySQL and PHP and I want to give a user-friendly error message when somebody tries to enter a duplicate record.
So instead of Duplicate entry ' ' for key 2, I want it to say something like ' this record has already been entered'.
Is there a way of writing user-friendly messages by seeing what kind of error occured or is the only way to do a select query on the database to see if the record exists. I don't want to do that if there's a better, less costly way of doing it.
Thanks
Hannah