Jump to content
jodunno

database error handling using php

Recommended Posts

Hello everyone,

quick description of 'error handling' so that everyone understands the solution i am seeking. let php and the database handle the error is not an appropriate answer here.

find out what i mean: using xampp, go to a login screen of your website, then turn off the database before submitting the login data. the connection will be attempted then fail. the browser will display its own error page which is white bg with a message. this is ridiculous. i made a custom handler that allows me to ignore this failure and show my own website with an error message.

now how can i detect an error with a select or update statement? i am not a db designer, so i really don't know how to do it. what say i fetch filed['testmyerror'] and it doesn't exist or there is a problem. how do i write php code that is used to ignore this problem and display my own message. naturally i will log the error and/or log and send email to myself.

anyone able to help? just a tip in the right direction?

Thank you very much, i appreciate this forum and its members always.

Share this post


Link to post
Share on other sites

Hello benanamen,

Thank you very much. I didn't know that i could do custom handling. I should probably read the php manual a little closer. My apologies for this lack of knowledge.

Best wishes.

Share this post


Link to post
Share on other sites
3 hours ago, benanamen said:

custom exemption function

Ooops, meant exception.

Share this post


Link to post
Share on other sites

Alternatively, configure your web server to show a particular page on error.  For apache you might do for example

ErrorDocument 500 /500.html

Exact configuration will depend on your server version and setup.

  • Like 1

Share this post


Link to post
Share on other sites

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.