470,849 Members | 1,166 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

Help for Error handing and logging in PHP

hi, all
We are running a php program for business. We want to hand the
error in the following way: Don't display the error messages but give
some other information such as our service telephone number and some
others. It is useful for our customers to get quick help when problems
happen.
How can i do that? Thanks for your suggestion!
Jul 17 '05 #1
3 1471
On Fri, 14 May 2004 00:10:38 +0800, Lian Liming wrote:
hi, all
We are running a php program for business. We want to hand the
error in the following way: Don't display the error messages but give
some other information such as our service telephone number and some
others. It is useful for our customers to get quick help when problems
happen.
How can i do that? Thanks for your suggestion!


I'm going to assume that you are running Apache. If you aren't, you will
have to specify which server you are using.

It can definately be done. A good place to start is
http://www.onlamp.com/pub/a/onlamp/2...avidsklar.html

- -
Mark J. Nenadov
Python Byte Solutions (http://www.pythonbyte.com/)

Jul 17 '05 #2
Lian Liming wrote:
We are running a php program for business. We want to hand the
error in the following way: Don't display the error messages but give
some other information such as our service telephone number and some
others. It is useful for our customers to get quick help when problems
happen.
How can i do that? Thanks for your suggestion!


Check out the PHP manual for error handling and logging
http://www.php.net/manual/en/ref.errorfunc.php

But it is better to not have errors in your scripts :)
Everytime a function can fail, test for failure and call an appropriate
function to deal with it
<?php // assume ALL_CAPS are define()'d constants
/* ... */
mysql_connect(DB_HOST, DB_USER, DB_PASS) or handle_error(ERR_CONN);
/* ... */
if ($x == 0) handle_error(ERR_DIV0);
/* ... */
?>

where the handle_error() function does whatever you want, including
sending HTML to the client with your service telephone number and other
data you might need.

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #3
Take a look at http://www.tonymarston.co.uk/php-mys...orhandler.html
which gives you an example on how to customise the PHP error handler.

You can change this so that any piece of text is shown on the client's
browser while a proper description of the error is written to a logfile
and/or emailed to the system administrator.

Easy peasy lemon squeezy.

--
Tony Marston

http://www.tonymarston.net

"Lian Liming" <ha**@123.com> wrote in message
news:2g************@uni-berlin.de...
hi, all
We are running a php program for business. We want to hand the
error in the following way: Don't display the error messages but give
some other information such as our service telephone number and some
others. It is useful for our customers to get quick help when problems
happen.
How can i do that? Thanks for your suggestion!

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Jerry | last post: by
10 posts views Thread by Brian Conway | last post: by
9 posts views Thread by Arvind R | last post: by
7 posts views Thread by flupke | last post: by
reply views Thread by Roopesh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.