Page 1 of 1

warning error regarding header

Posted: Sun Sep 30, 2007 11:00 pm
by rhardo
Hello Guys,

Newbie here as I am also a starter of php coding. I have encountered an error that says:

Warning: Header may not contain more than a single header (line 61)

The error points to particular code:

Code: Select all

echo header("Location: http://mydomain.com/reserve.php?property=$HN&field1=$F1&field2=$F2&field3=$F3&field4=$F4&field5=$F5&field6=$F6&field7=$F7&field8=$F8&mob_num=$F5a");
Please help... this is really URGENT. Thanks!

Posted: Sun Sep 30, 2007 11:30 pm
by feyd
Post the 10 lines above and below it.

Make sure to use

Code: Select all

...
tags.

Posted: Sun Sep 30, 2007 11:32 pm
by volka
Also please try

Code: Select all

$location = "Location: http://mydomain.com/reserve.php?propert ... b_num=$F5a";
die(" #$location# ");
// header($location);
and post the output.

btw: It's never echo header(), just header().

Posted: Mon Oct 01, 2007 12:01 am
by rhardo
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Thanks....
Actually, the form works fine on our computers and it does not generate such error. But we have received  reports from 2 different clients stating this kind of problem.

Any additional input?

Code: Select all

$error = "";
if($_POST[join])
{
	if (($F1 == "") || ($F2 == "") || ($F4 == "") || ($F5 == "") || ($F8 == ""))
	{
		echo "<script type='text/javascript'>alert('Please fill out all required fields. Press OK to go back.');</script>";
		$error = "1";
	}
else {$error = "";}
if ($error == "")
	{
		echo header("Location: http://mydomain.com/reserve.php?propert ... b_num=$F5a");
		$yes = "yes";
}
}

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Oct 01, 2007 12:07 am
by volka
I guess those $Fn variables are not urlencoded? They should be.
http://de2.php.net/urlencode

Posted: Mon Oct 01, 2007 1:00 am
by rhardo
Is urlencode a must?

Posted: Mon Oct 01, 2007 1:33 am
by volka
a) Does it hurt?
b) Yes, unless you want certain characters to "destroy" the url and/or the header
e.g.

Code: Select all

$HN="\n";
$F1=$F2=$F3=$F4=$F5=$F6=$F7=$F8=$F5a='';
header("Location: http://mydomain.com/reserve.php?propert ... b_num=$F5a");

Posted: Mon Oct 01, 2007 2:18 am
by rhardo
Thanks... I took ur advice regarding the integration of urlencode... are there any other causes of this so I can be assured that this error won't pop up again?