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.