警告:标题可能不包含多个标题,检测到新行

时间:2013-12-10 04:18:57

标签: php

我对PHP错误有疑问。我经历了其他类似的问题,并应用它,但我仍然有这样的问题,所以我问它。

情况是这样的。有一个叫做特殊指令的文本框;如果我只放一行就可以了,但是如果我放了多行就会导致这样的问题。我把urlencode(str)解决了问题,但它仍然出现了。我需要改变什么? T.T

错误消息是“警告:标题可能不包含多个标题,检测到新行。”

if($_POST['Submit'] == 'Submit Order'){
    $today = date('D M dY');
    $to_time = date('h:i a');
    $hours = substr($to_time, 0, -6);
    $minutes = substr($to_time, -5, 2);
    $seconds = substr($to_time, -2);
    $total_seconds = ($hours * 3600) + ($minutes * 60) + $seconds;

    $date123 = $_POST['day'];
    $date_post = date('D M dY',$date123);

    $time_post = $_POST['time']; 
    $hours_post   = substr($time_post, 0, -6);
    $minutes_post = substr($time_post, -5, 2);
    $seconds_post = substr($time_post, -2);
    $total_seconds_post = ($hours_post * 3600) + ($minutes_post * 60) + $seconds_post;

    $tip_amo = $_POST["tip_amount"];
    $deliv_mails = $_POST["deliv_mails"];
    $coupon_no = $_POST['coupon_no'];
    $minorder = $_POST['minorder'];
    $subtotal_amount = $_POST['subtotal_amount'];
    $payment_type = $_POST['payment_type'];
    $comments = addslashes($_POST['comments']);
    $coupon_code = $_REQUEST["coupon_code"];
    $customer_comments = get_field(CART,"additional_text","session_id='$sessionid'");

    if($comments == ''){
        $comments1 = $customer_comments;
    }else{
        $comments1 = $comments;
    }

    if($time_post!='') {
        if($today==$date_post){
            $query = [
                'day' => $date123,
                'time' => $time_post,
                'coupon_no' => $coupon_no,
                'minorder' => $minorder,
                'subtotal_amount' => $subtotal_amount,
                'payment_type' => $payment_type,
                'comments' => $comments1,
                'coupon_code' => $coupon_code,
                'tip_amount' => $tip_amo,
                'deliv_mails' => $deliv_mails,
                'd' => $address
            ];
            header('Location: details_info_order.php?' . http_build_query($query));
            exit;
        }else{
            $query = [
                'day' => $date123,
                'time' => $time_post,
                'coupon_no' => $coupon_no,
                'minorder' => $minorder,
                'subtotal_amount' => $subtotal_amount,
                'payment_type' => $payment_type,
                'comments' => $comments1,
                'coupon_code' => $coupon_code,
                'tip_amount' => $tip_amo,
                'deliv_mails' => $deliv_mails,
                'd' => $address
            ];
            header('Location: details_info_order.php?' . http_build_query($query));
            exit;
        }
    }
}
  

警告:标题可能不包含多个标题,检测到新行。在第64行的/home4/mikehan2/public_html/mikehan7/final_checkout_block.php

这是确切的错误消息。

2 个答案:

答案 0 :(得分:6)

你应该使用像http_build_query()这样的东西;无需手动URL编码,也不需要杂乱的字符串连接,例如

$query = array(
    'day' => $date123,
    'time' => $time_post,
    // etc
);
header('Location: details_info_order.php?' . http_build_query($query));
exit;

答案 1 :(得分:0)

您的某些变量包含多行文字,可能是COMMENTS。 使用urlencode

'comments' => urlencode($comments1),
...