2

I don't want to display errors in a screen, except that I want to save it in DB. I can't find any information about it. I think that it isn't difficult task, I just can't imagine how to orginize that...

Thank you a lot!

1
  • 2
    Rather than handling this with PHP, look into your web server's database logging facility. Any errors going on screen are also in your error log. Apache, for instance, has mod_log_sql Commented Mar 11, 2012 at 14:19

2 Answers 2

5

Use set_error_handler('myErrorFunction'); (See PHP Manual set_error_handler) define myErrorFunction with database inserts, turn off standard error reporting display with ini_get('display_errors', 0);

Sign up to request clarification or add additional context in comments.

Comments

1

In addition to set_error_handler(), which is the right answer, you can use normal logical operators to detect things that you think might fail. For example, it's common practice to use things like:

$h = @mysql_connect(...) or die();

You can similarly react to other failures with your own function instead of die(). The @ in front of the function tells it to be "silent" on errors.

Of course, if you're storing errors in a db, what happens if you can't talk to the db? :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.