Error log mysql record _ MySQL

Source: Internet
Author: User
Error log mysql record class. method
// Create an error log
Function error (){
$ Fp = @ fopen ("error. dat", "a + ");
$ 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 );
}

When you use mysql as a site, you must have an error that you don't know. how can you record it? Can I use mail to send emails to your mailbox? Are you sure you can receive the email? In linux, you can send root sendmail for maintenance purposes. But is there too many root emails? Create another user?

This directly creates an error log in your Directory
The above is the error record method in a class I used
This is called on the page that uses the mysql connection.

If (mysql_error ()){
$ Classname-> error ();
}

______________________________________________

Once an error occurs on your page, the information will not be leaked as long as you shield the hidden information.
Error. dat content is (eg .)

{VisitedTime: 14:43:56} {VisiterIP: 127.0.0.1} {Errormsg: Duplicate entry '0' for key 1} {File:->/path/errorfilename. php} {User: sports98}

I think this record will certainly be good for you to analyze your page.

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 so that you can solve the problem easily.

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.