0

警告:无法修改标头信息 - 标头已由 /srv/ 中的(输出开始于 /srv/disk2/1201823/www/-----------.org/Florida/bookingV1.php:1)发送disk2/1201823/www/------------.org/Florida/bookingV1.php

这是我得到的错误。我该如何解决?

这是我的代码。

<?php

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
    $x = $_POST['NoOfPass'] * 500;
    $insertSQL = sprintf("INSERT INTO booking2 (Lastname, Firstname, Email, Address, ContactNo, BusType, `From`, `To`, NoOfPass, DateMonth, `Day`, `Time`,Amount) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,$x)", 
            GetSQLValueString($_POST['Lastname'], "text"), 
            GetSQLValueString($_POST['Firstname'], "text"), 
            GetSQLValueString($_POST['Email'], "text"), 
            GetSQLValueString($_POST['Address'], "text"), 
            GetSQLValueString($_POST['ContactNo'], "int"), 
            GetSQLValueString($_POST['BusType'], "text"), 
            GetSQLValueString($_POST['From'], "text"), 
            GetSQLValueString($_POST['To'], "text"), 
            GetSQLValueString($_POST['NoOfPass'], "int"), 
            GetSQLValueString($_POST['DateMonth'], "text"), 
            GetSQLValueString($_POST['Day'], "int"), 
            GetSQLValueString($_POST['Time'], "text"));

    mysql_select_db($database_Connection, $Connection);
    $Result1 = mysql_query($insertSQL, $Connection) or die(mysql_error());

    $insertGoTo = "confirmation.php";
    if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
}
?>
4

2 回答 2

0

There should be no output before sending the headers.

According to the error report you're getting, there is something being outputted in the 1st line of the "bookingV1.php" script, which leads me to believe that the problem is a leading whitespace, text or HTML before the opening <?php marker.

于 2013-08-20T05:02:51.917 回答
0

确保您的代码,当您使用标头进行重定向时不要执行 echo 语句,并将 exit(); 标题语句的下一行。

喜欢

//echo 'do not do echo statement here'; if you uncomment this block you will get the same error again.
header('your location here');
exit();
于 2013-08-20T04:56:06.570 回答