0

我正在开发 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

在页面顶部,我正在连接数据库。但仍然为什么会出现这个错误......

有什么建议么...?

谢谢

4

1 回答 1

0

服务器连接超时并关闭连接。默认情况下,连接会在 8 小时后超时。如果您一直将其打开那么久,这可能不是一个好计划。请参阅@JohnBlake 评论。

于 2013-05-12T16:15:00.930 回答