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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.