Cannot modify header information - headers already sent

This is a discussion on "Cannot modify header information - headers already sent" within the PHP Forum section. This forum, and the thread "Cannot modify header information - headers already sent are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jan 31st, 2006, 19:11
Up'n'Coming Member
Join Date: Jan 2006
Location: East Sussex
Age: 27
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Question Cannot modify header information - headers already sent

Hi,

What does this mean exactly?

Cannot modify header information - headers already sent

My site was working with no problems at all when i was developing it on the local server but once i uploaded it to the internet server the above error message appears when i use the function below.

header("Location: home.php");

Any help would, as always, be gratefully recieved!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Feb 1st, 2006, 03:10
Reputable Member
Join Date: Sep 2005
Location: Canada, BC
Age: 24
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Cannot modify header information - headers already sent

Is there anything sent to the browser before the header? because thats what normaly gives that error, a echo, any white space or text outside of the <?php ?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Feb 1st, 2006, 13:20
Junior Member
Join Date: Nov 2005
Age: 29
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Cannot modify header information - headers already sent

Quote: "Note: The HTTP status header line will always be the first sent to the client,.........."
php.net
Always FIRST after open tags .. - remember this and have no more problem with HTTP protocol level
Example
<?php
header(..................

Regards
www.take-host.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Feb 1st, 2006, 20:47
Up'n'Coming Member
Join Date: Jan 2006
Location: East Sussex
Age: 27
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Cannot modify header information - headers already sent

Ok, so how should I do an automatic redirect? Also why was it working on my local machine but not when the file was uploaded to the internet?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Feb 2nd, 2006, 03:58
Reputable Member
Join Date: Sep 2005
Location: Canada, BC
Age: 24
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Cannot modify header information - headers already sent

Not sure, need to see some code to figure out exactly what is wrong...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Feb 2nd, 2006, 19:28
Junior Member
Join Date: Nov 2005
Age: 29
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Cannot modify header information - headers already sent

Some example again i will quote same page:
"<?php
header("Location: http://www.example.com/"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;?>"
Good luck
www.take-host.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Mar 12th, 2006, 04:26
Junior Member
Join Date: Mar 2006
Location: usa
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Cannot modify header information - headers already sent

RE your post on headers already sent---

"Ok, so how should I do an automatic redirect? Also why was it working on my local machine but not when the file was uploaded to the internet?"

im having the same problem - how did you solve your "headers already sent..." but works on local machine? Driving me nuts!!!!
David

david@mypilot.org
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Mar 12th, 2006, 17:34
Most Reputable Member
Join Date: Aug 2005
Location: North Wales, United Kingdom
Age: 21
Posts: 1,093
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Cannot modify header information - headers already sent

Ok heres how to solve the problem.
At the beginning of the page. before any HTML or any code is written type:
Code: Select all
<?php
ob_start();
?>
Now at the very bottom of the page after all the code type:
Code: Select all
<?php
ob_end_flush();
?>
You can now use headers, cookies and sessions wherever you want in your page with running into problems.

The function buffers all information between it before sending it to the browser.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
cannot, modify, header, information, headers, already, sent

Thread Tools

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Headers alexgeek Search Engine Optimization (SEO) 2 Jul 7th, 2008 09:08
Modify the DOM? gustaf JavaScript Forum 1 Sep 19th, 2007 23:01
3 choices 3 headers saltedm8 Graphics and 3D 12 Jun 24th, 2007 09:26
Form headers appearing bold Freddie PHP Forum 1 Dec 20th, 2005 14:26
Cannot modify header information - headers already sent Tim356 PHP Forum 2 Aug 7th, 2005 22:58


All times are GMT. The time now is 14:55.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42