Re: Re: One more 'Headers Already Sent' error. :-(
| From: | Brad Melendy | Date: | Wed, 26 Jun 2002 15:50:40 +0000 |
| Subject: | Re: Re: One more 'Headers Already Sent' error. :-( | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-103988@lists.php.net to get a copy of this message | ||
I wanted the script to redirect to different locations based on what
conditions were being met. My problem turned out that I had an include
statement including an html file prior to the header function on line 17.
If I understand this correctly, the include statement was providing 'output'
and then it was trying to output again later in the header() function. By
moving my include statement outside the <?php .....?> in the intial section
of code, it wasn't providing the output until after my header() function had
completed and there wasn't an issue anymore.
Thanks for your help.
...Brad
"Erik Price" <pricee@hhbrown.com> wrote in message
news:766A44A0-8905-11D6-9500-0050E4857868@hhbrown.com...
>
> On Tuesday, June 25, 2002, at 06:07 PM, Brad Melendy wrote:
>
> > Well, I have traced this down to line 4 in the following code
> > 'include("header.html");' which just includes my navigation bar. If I
> > comment it out, everything works great, if I leave it in, I get the
> > error
> > Headers Already Sent. The file it purely html. What could be the
> > problem??
> > Thanks in advance!
>
> You want this script to redirect twice? Or do you just want it to
> redirect the first time, but have the second header() function be called
> if the first one doesn't? Then you should call exit() after the first
> header() function to keep the rest of the script from executing.
>
> This is also generally a good practice after a header('Location: ') call
> because the user-agent doesn't HAVE to respect the header and redirect,
> so it protects your stuff. Always feature an exit() with a header-based
> redirect.
>
>
> Erik
>
>
>
>
> ----
>
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown
> pricee@hhbrown.com
>