warning error regarding header

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rhardo
Forum Newbie
Posts: 4
Joined: Sun Sep 30, 2007 10:54 pm

warning error regarding header

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post the 10 lines above and below it.

Make sure to use

Code: Select all

...
tags.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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().
rhardo
Forum Newbie
Posts: 4
Joined: Sun Sep 30, 2007 10:54 pm

Post 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I guess those $Fn variables are not urlencoded? They should be.
http://de2.php.net/urlencode
rhardo
Forum Newbie
Posts: 4
Joined: Sun Sep 30, 2007 10:54 pm

Post by rhardo »

Is urlencode a must?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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");
rhardo
Forum Newbie
Posts: 4
Joined: Sun Sep 30, 2007 10:54 pm

Post 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?
Post Reply