Today when I write a data import came out of the MySQL tutorial server has gone away first glance thought is the database tutorial hangs, but other normal, looks for the data from the website to discover, because the SQL statement is too long, thus surpasses the max_allowed_packet size, If this is the case, the SQL statement is carefully instrumented as follows:
while ($rs = Mysql_fetch_array ($query))
{
$os = Autoaddlink ($os);
Insert .... Data preservation,
}
Functions are as follows
function Autoaddlink ($STR)
{
$spath = ' {cmspath} ';
$sql = "Select Typename,id,typedir from 3g_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 (' Mobile 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 face code not careful to see is not always found, we see
$os = Autoaddlink ($os);
Insert .... Data preservation,
If it is not a problem to put the while loop alone, if it is possible to import SQL too long, the reason why I do not say that a variable lifetime problem.