Current location: Hot Scripts Forums » Programming Languages » PHP » Warning: Cannot modify header information - headers already sent by!!! help!!!!


Warning: Cannot modify header information - headers already sent by!!! help!!!!

Reply
  #1 (permalink)  
Old 11-09-06, 11:05 AM
Enigma122 Enigma122 is offline
Newbie Coder
 
Join Date: Nov 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Talking Warning: Cannot modify header information - headers already sent by!!! help!!!!

i need help with header command use, couse i try many time but it dosnt woks im worry couse i have no time to finish my homework, im asking for any help, may be some one can help me, my code:
PHP Code:

<?


//Set your redirection URL here
$URL="../Almacen.html";
header ("Location: $URL");
echo 
"<title>Redirecting to $URL</title>";

?>
i try commads like start_session(); and like this :
PHP Code:

 $user=$_SERVER['REMOTE_USER'];

if (
$user=="john")
 {
  
header("Location: http://johnspage.com");
 }
else
 {
  
header ("Location: http://everyoneelse.com");
 } 
Warning: Cannot modify header information - headers already sent by

BUT NO ONE WORK I DONT KNOW IF I HAVE TO USE OTHER COMMAND OR A CLASS OR ???????????????? I JUST NEDD HELP!!!!! OR SEND ME A WORKING EXAMPLE TO MY MAIL bernardoavilaz@yahoo.com.mx, thnxz for any help

Last edited by Nico; 11-09-06 at 11:09 AM. Reason: Please use [php] wrappers when posting PHP code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-09-06, 11:20 AM
odi's Avatar
odi odi is offline
Newbie Coder
 
Join Date: Oct 2006
Location: Switzerland
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
You must check that before the header() command there is no other output, it must be the very first to be done.

Sometimes there is a space or something before the PHP-Command, this can lead to this kind of error.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 11-09-06, 11:42 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
also, i think what you need is either javascript or html, as you want to output first that you will redirect the user.
the header function will send the user directly to the other page, without showing the rest of the page.

It is also best to place
PHP Code:

exit; 

after calling the header function, to make sure nothing is being executed after the header, and no errors will ocure.

if you want to show something to the user, before redirecting him, try this:
PHP Code:

$URL "../Almacen.html";

echo 
"<strong>Redirecting to $URL</strong>";
echo 
"<meta http-equiv='refresh' content='3;url=$URL'>"
this will redirect the user after 3 seconds

Greetz,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 11-10-06, 01:40 AM
dflies's Avatar
dflies dflies is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
ob_start();
Put that on the top of the page and
ob_flush();
to the bottom of your page.
It should work.
__________________
Dflies' Paradise
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 11-10-06, 07:02 PM
Enigma122 Enigma122 is offline
Newbie Coder
 
Join Date: Nov 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
really thanxz!! all of
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using BigDump(#20922) rAyVax PHP 5 05-14-06 01:14 PM
Warning: Cannot modify header information GrnEydGuy PHP 4 03-09-06 01:45 AM
Modify headers information mcrob PHP 2 11-18-05 06:02 PM
Warning: Cannot modify header information - headers already sent by netbakers PHP 1 07-09-05 01:55 AM
cannot modify header kalinchuk PHP 13 06-02-05 02:18 AM


All times are GMT -5. The time now is 11:03 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.