Getting Warning "Header May Not Contain More Than a Single Header, New Line Detected"

Header may not contain more than a single header, new line detected error

Okay, this one was a toughie but I figured it out. Here is my method:

  1. So the clue lies in the error itself. It was pointing me from my processing php. But it was only because the data being asked in the header (requires a reference ID) is wrong.
  2. The problem was in the reference ID (after much debugging). It was taking the wrong value from the wrong variable. This was in the php form page not the php processing page.

So here is the solution:

$s->bindvalue(':refid', $refid);

Rest of the code:

<input type="hidden" name="ref_id" value="<?php echo $rid; ?>" >

The variable $rid is not the same as the variable $refid.

Here is the fix:

<input type="hidden" name="ref_id" value="<?php echo $refid; ?>" >

This means that with this type of error, it might be worth looking at which part of the code it is trying to get the value from and start debugging from there.

Thanks for the help everyone!

Warning: Header may not contain more than a single header, new line detected

You should really use something like http_build_query(); no need to manually URL encode and no messy string concatenation, eg

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

Php: Warning: Header may not contain more than a single header, new line detected in

What is unclear about the error?

You have a new line here:

\r\n

You are trying to set two headers. You need two header() statements instead of one with a line break in the string.

header("Pragma: public");
header("Expires: 0");
die();


Related Topics



Leave a reply



Submit