mds1256 Posted December 29, 2012 Share Posted December 29, 2012 Hi What would you say the best practice was to handle a mysql / PHP error. These errors include a SQL query problem, mysql connection problem, any sort of php problem. I have read that all errors should be output to a log so I can keep an eye on any errors etc, but what about displaying errors to users? So say that my website had a problem with a mysql connection, should I just re-direct the user to a static type error page to say there was a problem (as my site relies on a database connection to supply content etc). Also with a SQL query, I am guessing that I should just display a custom error for the action they are trying to perform, e.g. logging in; I should just echo there was a problem logging in. And then pipe the proper php error to a log file? Any tips would be great? Link to comment https://forums.phpfreaks.com/topic/272496-best-way-to-handle-a-mysql-or-php-error/ Share on other sites More sharing options...
Pikachu2000 Posted December 29, 2012 Share Posted December 29, 2012 If you want to display an error to the user, make it a generic "Sorry, your stupid request cratered the database server" type of message, and log the system generated error. Showing the user the system generated message is a bad idea since it usually contains information they wouldn't otherwise have access to, or even need. Link to comment https://forums.phpfreaks.com/topic/272496-best-way-to-handle-a-mysql-or-php-error/#findComment-1402074 Share on other sites More sharing options...
mds1256 Posted January 4, 2013 Author Share Posted January 4, 2013 Thanks Link to comment https://forums.phpfreaks.com/topic/272496-best-way-to-handle-a-mysql-or-php-error/#findComment-1403209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.