Jump to content

Best Way To Handle A Mysql Or Php Error


mds1256

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.