How to record unknown errors when using mysql as a site

Source: Internet
Author: User

When MySQL is used as a site, unknown errors may occur. How can this problem be recorded? The solution is as follows:
Class. method

 

// Create an error log

Function error (){

+ ");

$ Time = date ("Y-m-d H: I: s ");

$ Msg = "{VisitedTime: $ time}

{VisiterIP: $ _ SERVER [REMOTE_ADDR]}

{Errormsg: ". MySQL_error ()."}

{File:-> $ _ SERVER [PHP_SELF]}

{User: $ _ SESSION [user]} ";

@ Fputs ($ fp, $ msg );

@ Fclose ($ fp );

} The above Code is an error record method in the class I used. This is called on the page that uses the MySQL connection. The following code directly creates an error log in your directory.
If (MySQL_error ()){

$ Classname-> error ();

}

 

________________________ If an error occurs on your page, the information will not be leaked as long as you shield the page for concealment. The error. dat content is set to (eg.) in this directory .)

{VisitedTime: 2002-05-09 14:43:56}

{VisiterIP: 127.0.0.1}

{Errormsg: Duplicate entry 0 for key 1}

{File:->/path/errorfilename. PHP}

Records such as {User: sports98} are certainly good for analysis pages.

If you are using include, do not add _ LINE _. If you are using require, we recommend that you add _ LINE _ to help you quickly locate the error and solve the problem.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.