我正在使用Flight门户网站。让我们假设有两个页面(Search.php,Result.php)。
在搜索页面中,我们将选择旅程的来源,目的地,日期......(现在我们将点击搜索按钮)
点击搜索按钮后,页面将重定向到Result.php,我们将在那里显示结果。
在显示页面上的结果之前,我试图将这些结果插入数据库,如下所示。
$q=0;
foreach($array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'] as $main)
{
$basefare[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['ActualBaseFare'];
$tax[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['Tax'];
$stax[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['STax'];
$tcharge[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['TCharge'];
$scharge[$q]=$array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['FareDetails']['SCharge'];
$totalfare[$q]=$basefare[$q]+$tax[$q]+$stax[$q]+$tcharge[$q]+$scharge[$q];
$s=0;
foreach($array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption'][$q]['onward']['FlightSegments']['FlightSegment'] as $array)
{
$z1=$flightnumber[$q][$s]=$array['FlightNumber'];
$z2=$departureloc[$q][$s]=$array['DepartureAirportName'];
$z3=$departurecode[$q][$s]=$array['DepartureAirportCode'];
$z4=$arrivalloc[$q][$s]=$array['ArrivalAirportName'];
$z5=$arrivalcode[$q][$s]=$array['ArrivalAirportCode'];
$z6=$departuretime[$q][$s]=$array['DepartureDateTime'];
$z7=$arrivaltime[$q][$s]=$array['ArrivalDateTime'];
$z8=$airlinename[$q][$s]=$array['OperatingAirlineName'];
$z9=$airlineflightnumber[$q][$s]=$array['OperatingAirlineFlightNumber'];
$z10=$airlinecode[$q][$s]=$array['OperatingAirlineCode'];
echo $mysql_query="insert into RviewInternationalFlight (q,s,FlightNumber,OperatingAirlineName,OperatingAirlineFlightNumber,OperatingAirlineCode,DepartureAirportName,DepartureAirportCode,ArrivalAirportName,ArrivalAirportCode,DepartureDateTime,ArrivalDateTime,ip) values('$q','$s','$z1','$z2','$z3','$z4','$z5','$z6','$z7','$z8','$z9','$z10','$ip'
)";
mysql_query($mysql_query) or die(mysql_error());
$s++;
}
$q++;
}
它应该可以正常工作,但我收到错误MySQL server has gone away
。
在页面顶部,我正在连接数据库。但仍然存在错误的原因......
有任何建议......?
由于
答案 0 :(得分:0)
服务器连接超时并关闭连接。默认情况下,连接在8小时后超时。如果你一直把它打开那么久,这可能不是一个好计划。见@JohnBlake评论。