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

You may get this error when you are dealing with lot of variables and trying to passing those variable to header and by a mistake you have new line in your header string.

i was getting this following error when redirecting after form submit..

“Warning: Header may not contain more than a single header, new line detected. in /home/gedforad/public_html/index.php on line 60”

So i was thinking there may be the problem with redirect it with lot of variables but it was not!

there may be you have some code like this


$post_url="Location: http://webservices.somewebsite.com/default.ashx?"."&state=".$state."&country=".$country;

header($post_url);

Or whatever code you have with lot of variable.its most common when press enter to go to new line.

here i am using location within string , otherwise actual code should be(this is also a way to avoid errors):


$post_url="http://webservices.somewebsite.com/default.ashx?"."&state=".$state."&country=".$country."&email=".$email."&ReturnToURL=".$ReturnToURL;

header("Location: $post_url");

you will get an error if you will have some new line in your $post_url variable string.

just test your code again and remove new line in your code, you can post lot of variable through browser.

  • Adam

     i have no line but i am still getting this error.
    any idea?