Jump to content

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


denoteone

Recommended Posts

$headers  = "Content-type: text/html; charset=utf-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
header($headers);

 

this my code on line 35 this is the error message in my http log?

PHP Warning:  Header may not contain more than a single header, new line detected. in :FileName" on line 35, referer: "##sitename###"

do I need to remove the "\n" in the second part of the header varialbe?

No, you need to output each header line individually:

header("Content-type: text/html; charset=utf-8");
header("Content-Transfer-Encoding: 8bit");

and without the \r\n, let PHP do that for you

I took out the second "\r\n"

 

so now I have

$headers  = "Content-type: text/html; charset=utf-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit";
header($headers);

 

Doesn't look as if I am getting the error any more. Does that sound right? 

Let me repeat what I said with added emphasis:

No, you need to output each header line individually:

header("Content-type: text/html; charset=utf-8");
header("Content-Transfer-Encoding: 8bit");

and without the \r\n, let PHP do that for you

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.