Help for Error handing and logging in PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lian Liming

    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!
  • Mark J. Nenadov

    #2
    Re: Help for Error handing and logging in PHP

    On Fri, 14 May 2004 00:10:38 +0800, Lian Liming wrote:
    [color=blue]
    > 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![/color]

    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
    Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology


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

    Comment

    • Pedro Graca

      #3
      Re: Help for Error handing and logging in PHP

      Lian Liming wrote:[color=blue]
      > 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![/color]

      Check out the PHP manual for error handling and logging




      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(D B_HOST, DB_USER, DB_PASS) or handle_error(ER R_CONN);
      /* ... */
      if ($x == 0) handle_error(ER R_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 :

      Comment

      • Tony Marston

        #4
        Re: Help for Error handing and logging in PHP

        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

        This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL




        "Lian Liming" <haha@123.com > wrote in message
        news:2ghkgnF2vv 28U1@uni-berlin.de...[color=blue]
        > 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![/color]


        Comment

        Working...