MySQL server has gone away method and cause

Source: Internet
Author: User
Tags mysql tutorial

Today, when I wrote a data import, I came up with the mysql tutorial server has gone away. At first glance, I thought it was a database tutorial, but the other was normal. I found it from my website, the reason is that the SQL statement is too long and exceeds the size of max_allowed_packet. If so, the SQL statement is carefully checked as follows:

While ($ rs = mysql_fetch_array ($ query ))

{

$ OS = autoaddlink ($ OS );

Insert... save data,

}

The function is as follows:

Function autoaddlink ($ str)
{
$ Spath = '{cmspath }';
$ SQL = "select typename, id, typedir from cmd_arctype where topid <> 175 ";
$ Query = mysql_query ($ SQL) or die (mysql_error ());
$ Tmps tutorial tr = strtolower ($ str );
 
While ($ rs = mysql_fetch_array ($ query ))
{
$ Rs ['typename'] = strtolower (str_replace ('cell phone theme ', '', str_replace ('Theme','', str_replace ('nokia ','', $ rs ['typename']);
$ Tmpstr = str_replace ($ rs ['typename'], "<a href = "". str_replace ($ spath, '', $ rs ['typedir']). ""> ". $ rs ['typename']. "</a>", $ tmpstr );

}
Return $ tmpstr;
}

From the perspective of the code, we can't find it.

$ OS = autoaddlink ($ OS );

Insert... save data,

If you do not place the SQL statement in the while LOOP alone, there is no problem. If you place the SQL statement in it, it may take too long to import the SQL statement. I won't say it because it is a variable survival 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.