Warning: Cannot modify header information

Reply

Join Date: Jan 2006
Posts: 29
Reputation: rcasinillo_s is an unknown quantity at this point 
Solved Threads: 0
rcasinillo_s rcasinillo_s is offline Offline
Light Poster

Warning: Cannot modify header information

 
0
  #1
Jan 21st, 2006
Good day!

Could somebody help me with this problem:
When i'm using header() to redirect page it giving me error message like this:
Warning: Cannot modify header information - headers already sent by (output started at /exxport/www/httdocs/waff/teng/HTML/Jobss/loginn_hrm.ph
p:10) /exxport/www/httdocs/waff/teng/HTML/Jobss/loginn_hrm.phpon line 336


Thanks...

Roland (rcasinillo_s)
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 9
Reputation: kulinh is an unknown quantity at this point 
Solved Threads: 0
kulinh kulinh is offline Offline
Newbie Poster

Re: Warning: Cannot modify header information

 
0
  #2
Jan 21st, 2006
use header() at top of page ( HTML ) that u redirect or u will have that error !!!
header(); <html>
nor <html> header();
oke !!!
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 29
Reputation: rcasinillo_s is an unknown quantity at this point 
Solved Threads: 0
rcasinillo_s rcasinillo_s is offline Offline
Light Poster

Re: Warning: Cannot modify header information

 
0
  #3
Jan 21st, 2006
Originally Posted by kulinh
use header() at top of page ( HTML ) that u redirect or u will have that error !!!
header(); <html>
nor <html> header();
oke !!!
Thank you for your responsed, but still not working I'm thinking may be it conflicts with the session_start() that i have placed on the top of the page code. What do you think?

Or is there any methods, ways to use as page redirection besides, header() function?

Is there anybody could help!

Roland
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 9
Reputation: kulinh is an unknown quantity at this point 
Solved Threads: 0
kulinh kulinh is offline Offline
Newbie Poster

Re: Warning: Cannot modify header information

 
0
  #4
Jan 21st, 2006
can u post your code here ??
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 138
Reputation: sarahk is an unknown quantity at this point 
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

Re: Warning: Cannot modify header information

 
0
  #5
Jan 22nd, 2006
header() doesn't have to be at the very top of your code but it does have to be before there is even one character sent to the browser. This might be a blank line before the <?php or maybe you include header.php before you process the page - well you can't do that if you want to keep your options open.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 29
Reputation: rcasinillo_s is an unknown quantity at this point 
Solved Threads: 0
rcasinillo_s rcasinillo_s is offline Offline
Light Poster

Re: Warning: Cannot modify header information

 
0
  #6
Jan 23rd, 2006
Originally Posted by sarahk
header() doesn't have to be at the very top of your code but it does have to be before there is even one character sent to the browser. This might be a blank line before the <?php or maybe you include header.php before you process the page - well you can't do that if you want to keep your options open.

Thanks Sarahk! excellent....

Roland
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 29
Reputation: rcasinillo_s is an unknown quantity at this point 
Solved Threads: 0
rcasinillo_s rcasinillo_s is offline Offline
Light Poster

Re: Warning: Cannot modify header information

 
0
  #7
Jan 23rd, 2006
Originally Posted by kulinh
use header() at top of page ( HTML ) that u redirect or u will have that error !!!
header(); <html>
nor <html> header();
oke !!!
Thank you Kulinh, you're right! My code is now working....

Thank you...Thank you...Thank you...

Roland
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 57
Reputation: bwest is an unknown quantity at this point 
Solved Threads: 1
bwest's Avatar
bwest bwest is offline Offline
Junior Poster in Training

Re: Warning: Cannot modify header information

 
0
  #8
Jan 26th, 2006
Here's how header() works

You can put header("Location: whateverpage.php"); anywhere you want. Top/bottom of script doesnt matter. What is important is to put exit(); right after. The reason being that all your doing with the header call is changing the headers, the script wants to finnish before it uses those new headers. So if you stop the script then you will redirect the page.

Also, if you tried echoing or printing anything to the screen before header(), then it wont work because you're basiclly trying to say you want a page returned to the user yet you also want to go to another page. When you echo, you are saying that the current heading is what you want. So thats why when you change the heading later it says "Cant change header"

-B
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,075
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Warning: Cannot modify header information

 
0
  #9
Jan 30th, 2006
like sarahk said, as soon as their is some http output, you cannot modify the headers. This is a restriction of the http protocol.
PHP can also buffer http output and only send the output when you want it to using the ob_start() and ob_end_flush().

This is also useful in many other situations, but especially in yours where you want to modify the http header information anywhere withing the script.

so if you call ob_start(); on the first line of your executing php file, then whenever you want to make a header redirect, you just call header() then exit();.

note: I believe exit will automatically flush the http headers. If not then you have to call ob_end_flush(); before exit.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 11
Reputation: trochia is an unknown quantity at this point 
Solved Threads: 0
trochia trochia is offline Offline
Newbie Poster

Re: Warning: Cannot modify header information

 
0
  #10
Jan 1st, 2009
Hello all here on DW, and even though I've popped in here a couple of times...this is my first post.

I also do know want you to think I am "hijacking a thread", but I also am having a
header("Refresh: 1;url=http://www.TheWebsite.com/thankyou.php");
problem that is beating me up.

Instead of creating a new thread, like most others like..I personally feel that keeping a subject "on a direct topic" is best, as searching thru a forum...for a subject with the same topic...and reading them all, well.. I feel redundancy.

I will be more than happy to if required though.

My problem

I am also getting the error, in a normal situation doing "page by page", it isn't a problem, but I am trying to redirect after a "form submit" that is placed globally in the left pane of the site. (ie...displayed on all pages of the site, and pulled with what the original programmer used as "left.php"

The form it self, is submitted then into /js/ajax_form.php in which I have tried all the above...and still get this error.

file "left.php" (in which is all html) and I place it...no errors, and does nothing.

I am really lost on this one, and am thinking I am going to have to place it globally?

Thx for taking the time to read this,

T~
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC