Cannot add header information - headers already sent

This is a discussion on Cannot add header information - headers already sent within the PHP General forums, part of the PHP Programming Forums category; Hi all, I’m stuck with this one: I have an checkout procedure: when people come to the overview page(...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-12-2003
Frederik Feys
 
Posts: n/a
Default Cannot add header information - headers already sent

Hi all,

I’m stuck with this one:
I have an checkout procedure: when people come to the overview page(step
2), they get:

Warning: Cannot add header information - headers already sent by (output
started at
/usr/local/www/vhosts/aurelis.org/htdocs/header_aurelis.php:95) in
/usr/local/www/vhosts/aurelis.org/htdocs/store/includes/functions/get_ca
rtID.php on line 14

header_aurelis.php is where actual html output starts (template)
i had a similar problem in my cart. I solved this by adding at the top
of my script:
$cookie = GetCartId();
This doesn’t do the trick now :-(

For your convenience i put the code here:
http://www.aurelis.org/store/checkout_form.txt
and a handler file:
http://www.aurelis.org/store/checkout_form_handler.txt

Can anyone shed some light on this?

Thanks!
Fré


Reply With Quote
  #2 (permalink)  
Old 08-12-2003
Marek Kilimajer
 
Posts: n/a
Default Re: [PHP] Cannot add header information - headers already sent

output started at
/usr/local/www/vhosts/aurelis.org/htdocs/header_aurelis.php:95

says it all. Look into the file at line 95.

frederik feys wrote:
> Hi all,
>
> I’m stuck with this one:
> I have an checkout procedure: when people come to the overview page(step
> 2), they get:
>
> Warning: Cannot add header information - headers already sent by (output
> started at
> /usr/local/www/vhosts/aurelis.org/htdocs/header_aurelis.php:95) in
> /usr/local/www/vhosts/aurelis.org/htdocs/store/includes/functions/get_ca
> rtID.php on line 14
>
> header_aurelis.php is where actual html output starts (template)
> i had a similar problem in my cart. I solved this by adding at the top
> of my script:
> $cookie = GetCartId();
> This doesn’t do the trick now :-(
>
> For your convenience i put the code here:
> http://www.aurelis.org/store/checkout_form.txt
> and a handler file:
> http://www.aurelis.org/store/checkout_form_handler.txt
>
> Can anyone shed some light on this?
>
> Thanks!
> Fré
>
>


Reply With Quote
  #3 (permalink)  
Old 08-13-2003
Frederik Feys
 
Posts: n/a
Default RE: [PHP] Cannot add header information - headers already sent

Hi Marek, hi all,

What do you mean by "says it all"? On that line the page title is
outputted.

I suspect something is wrong with the handler file:
http://www.aurelis.org/store/checkout_form_handler.txt

When i call http://www.aurelis.org/store/checkout_form.txt
for step 1 (i.e. client personal register form) checkout_form gives no "
headers already sent". When the client proceeds to step 2 (i.e. an
overview of purchase) the checkout_form_handler file is called.
This does some calculations, etc.. and then redirects user to proper
page using an header(location:) call.
I suspect this step gives the "header already sent".

Any help appreciated!

Fré


-----Original Message-----
From: Marek Kilimajer [mailto:kilimajer@webglobe.sk]
Sent: dinsdag 12 augustus 2003 12:15
To: frederik feys
Cc: php-general@lists.php.net
Subject: Re: [php] Cannot add header information - headers already sent

output started at
/usr/local/www/vhosts/aurelis.org/htdocs/header_aurelis.php:95

says it all. Look into the file at line 95.

frederik feys wrote:
> Hi all,
>
> I’m stuck with this one:
> I have an checkout procedure: when people come to the overview

page(step
> 2), they get:
>
> Warning: Cannot add header information - headers already sent by

(output
> started at
> /usr/local/www/vhosts/aurelis.org/htdocs/header_aurelis.php:95) in
>

/usr/local/www/vhosts/aurelis.org/htdocs/store/includes/functions/get_ca
> rtID.php on line 14
>
> header_aurelis.php is where actual html output starts (template)
> i had a similar problem in my cart. I solved this by adding at the top
> of my script:
> $cookie = GetCartId();
> This doesn’t do the trick now :-(
>
> For your convenience i put the code here:
> http://www.aurelis.org/store/checkout_form.txt
> and a handler file:
> http://www.aurelis.org/store/checkout_form_handler.txt
>
> Can anyone shed some light on this?
>
> Thanks!
> Fré
>
>




Reply With Quote
  #4 (permalink)  
Old 08-13-2003
Marek Kilimajer
 
Posts: n/a
Default Re: [PHP] Cannot add header information - headers already sent

You need to rethink your code logic. Any headers, be it cookies, cookies
from session_start(), header() calls, must be send before any content,
content is what you can see if you select "view source" and comes from
echo, print, printf, errors and warnings, or anything that is outside of
<?php ?>. Or use output buffering.

frederik feys wrote:

> Hi Marek, hi all,
>
> What do you mean by "says it all"? On that line the page title is
> outputted.
>
> I suspect something is wrong with the handler file:
> http://www.aurelis.org/store/checkout_form_handler.txt
>
> When i call http://www.aurelis.org/store/checkout_form.txt
> for step 1 (i.e. client personal register form) checkout_form gives no "
> headers already sent". When the client proceeds to step 2 (i.e. an
> overview of purchase) the checkout_form_handler file is called.
> This does some calculations, etc.. and then redirects user to proper
> page using an header(location:) call.
> I suspect this step gives the "header already sent".
>
> Any help appreciated!
>
> Fré
>
>
> -----Original Message-----
> From: Marek Kilimajer [mailto:kilimajer@webglobe.sk]
> Sent: dinsdag 12 augustus 2003 12:15
> To: frederik feys
> Cc: php-general@lists.php.net
> Subject: Re: [php] Cannot add header information - headers already sent
>
> output started at
> /usr/local/www/vhosts/aurelis.org/htdocs/header_aurelis.php:95
>
> says it all. Look into the file at line 95.
>
> frederik feys wrote:
>
>>Hi all,
>>
>>I’m stuck with this one:
>>I have an checkout procedure: when people come to the overview

>
> page(step
>
>>2), they get:
>>
>>Warning: Cannot add header information - headers already sent by

>
> (output
>
>>started at
>>/usr/local/www/vhosts/aurelis.org/htdocs/header_aurelis.php:95) in
>>

>
> /usr/local/www/vhosts/aurelis.org/htdocs/store/includes/functions/get_ca
>
>>rtID.php on line 14
>>
>>header_aurelis.php is where actual html output starts (template)
>>i had a similar problem in my cart. I solved this by adding at the top
>>of my script:
>>$cookie = GetCartId();
>>This doesn’t do the trick now :-(
>>
>>For your convenience i put the code here:
>>http://www.aurelis.org/store/checkout_form.txt
>>and a handler file:
>>http://www.aurelis.org/store/checkout_form_handler.txt
>>
>>Can anyone shed some light on this?
>>
>>Thanks!
>>Fré
>>
>>

>
>
>
>


Reply With Quote
  #5 (permalink)  
Old 08-14-2003
Justin French
 
Posts: n/a
Default Re: [PHP] Cannot add header information - headers already sent

To be more descriptive than Marek, some text (in this case the TITLE)
has been sent to the browser around line 95 of header_aurelis.php. The
reason you are getting this warning is because PHP is trying to send a
header (redirect in this case) to the browser, but it cannot, because
the output has already started.

Clean up header_aurelis.php and make sure there's no browser output
before the redirect.

Yes, this means you might have to re-structure your script, or as a
last result, you may consider using the OB (out buffering) functions.


Justin


On Wednesday, August 13, 2003, at 06:52 PM, frederik feys wrote:

> What do you mean by "says it all"? On that line the page title is
> outputted.
>
> I suspect something is wrong with the handler file:
> http://www.aurelis.org/store/checkout_form_handler.txt
>
> When i call http://www.aurelis.org/store/checkout_form.txt
> for step 1 (i.e. client personal register form) checkout_form gives no
> "
> headers already sent". When the client proceeds to step 2 (i.e. an
> overview of purchase) the checkout_form_handler file is called.
> This does some calculations, etc.. and then redirects user to proper
> page using an header(location:) call.
> I suspect this step gives the "header already sent".
>
> -----Original Message-----
> From: Marek Kilimajer [mailto:kilimajer@webglobe.sk]
> Sent: dinsdag 12 augustus 2003 12:15
> To: frederik feys
> Cc: php-general@lists.php.net
> Subject: Re: [php] Cannot add header information - headers already sent
>
> output started at
> /usr/local/www/vhosts/aurelis.org/htdocs/header_aurelis.php:95
>
> says it all. Look into the file at line 95.


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:34 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0