/    Sign up×
Community /Pin to ProfileBookmark

header() Issue

Warning: Cannot modify header information – headers already sent by (output started at e:websiteslocalhostdo.php:2) in e:websiteslocalhostdo.php on line 2

Humf! Is that a server set thing or what?

to post a comment
PHP

12 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryApr 18.2005 — The first thing to check is if you have anything in your file before the start of the PHP code, even spaces. If so, move it. Otherwise, you are sending output prior to calling header(), and you will probably need to show us the code to get additional help.

Adam
Copy linkTweet thisAlerts:
@imnoguruauthorApr 18.2005 — <?php

header("Location: $location");

exit;

?>

with no spaces before the code, and no html included. Working on a redirection form.

-im no guru?
Copy linkTweet thisAlerts:
@AdamGundryApr 18.2005 — Hmm...it could be a problem with your server setup, for example if you have auto_prepend_file set in one of the PHP or Apache config files, but it'd be quite unusual. Where is the $location variable coming from?

Adam
Copy linkTweet thisAlerts:
@imnoguruauthorApr 18.2005 — A form page...

<form METHOD="post" action="do.php">

<p>Send me to: <select name="location">

blah blah blah

so on and so forth..

well with previous scripts I wrote, I had an error check added in and it doesn't seem to work with header() gives me the same error message, which lead me to think its a server setting somewhere..

imnoguru
Copy linkTweet thisAlerts:
@EJMAES1973Apr 18.2005 — Is there anyway you could give us the entire code for that page? That would really help.

Jason
Copy linkTweet thisAlerts:
@imnoguruauthorApr 18.2005 — Is there anyway you could give us the entire code for that page? That would really help.[/QUOTE]

Uhmm...if your refering to the php code, I already gave it.

Like I said I am just working on a redirect.

<?php header("Location: $location");

exit;

?>

and well...here is the form..but I think everything looks good in the form..

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>redirection</title>

</head>

<body>

<FORM METHOD="post" action="do.php">

<p>Send me to:

<select name="location">

<option value="http://www.dustofearth.com/">DustofEarth</option>

<option value="http://www.msn.com/">Msn</option>

</select></p>

<p><input type="submit" name="submit" value="Go!"></p>

</form>

</body>

</html>

imnoguru
Copy linkTweet thisAlerts:
@EJMAES1973Apr 18.2005 — Oh, im sorry...i thought there was more to the page.

Is that the only thing on your page or do you have the html part

[code=html]<head>whatever</head>[/code]

on the page also?
Copy linkTweet thisAlerts:
@imnoguruauthorApr 18.2005 — That is [B]exactly[/B] whats on both pages?
Copy linkTweet thisAlerts:
@EJMAES1973Apr 18.2005 — Okay well if your header redirect is after the <head></head> section of your document then you can't do that.
Copy linkTweet thisAlerts:
@imnoguruauthorApr 18.2005 — Im not quiet sure what your refering to?? The redirect php code is in its own file, all by its lonesome. Which means there is NOTHING before it and NOTHING after it, which also means there is no <head></head> tags anywhere in the *.php file? Is that what you mean??

-imnoguru
Copy linkTweet thisAlerts:
@imnoguruauthorApr 18.2005 — Thanks to everyone that tried? I needed to $_POST my variable in the same block as the header() operation.

-imnoguru
Copy linkTweet thisAlerts:
@EJMAES1973Apr 18.2005 — Yah thats what i meant. Well at least you figured out what was wrong ?
×

Success!

Help @imnoguru spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...