Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another "cannot add header information"

Status
Not open for further replies.

PaulFynch

IS-IT--Management
May 23, 2002
105
CA
<phpnewbie>
Hey there;
I have read (i think) just about all the &quot;cannot add header information&quot; threads and i KNOW there aren't any white spaces or extra carriage returns in this script, etc. Is there something in the php.ini that would prevent this header from working????


<body>
<?php
header('HTTP/1.0 401 Unauthorized');
?>
</body>


i still get:

Warning: Cannot add header information - headers already sent by (output started at C:\mysillysite\ in C:\mysillysite\ on line 8

where line 7 is the '<?php'
Thanks in advance
Paul
</phpnewbie>
 
You are outputting &quot;<body>&quot; first! Do this instead:
<?php
header('HTTP/1.0 401 Unauthorized');
?>

Rick If I have helped you just click the first link below to let me know :)
 
<paul>
hey rick,
thanks for the speedy response!!
i took the body tags out, but it still didn't change anything.
Now i am new to php so i dont totally understand all the ins and outs, and this page is just a little test to figgure out what i am doing wrong with the header to get my user authentication thinger workin. I thought maybe something in the php.ini cuz i cant seem to get any header script to work.
Thankx again
Paul
</paul>
 
Make a blank page with only this on it:
<?
header(&quot;Location: page.html;&quot;);
?>

See if that works. It should take you to a page called page.html, and that page probably doesn't exist on your server, you see if you get a page not found error.

Rick If I have helped you just click the first link below to let me know :)
 
Run this script. Does it give errors?

[tt]
Code:
<?php

header (&quot;X-Foo: foo&quot;);

print &quot;<html><body>foo</body></html>&quot;;

?>
[/tt]
 
<paul>
hey sleipner,
same &quot;cannot add header information&quot;
and then&quot;foo&quot; (of course)
any other ideas?
thx
</paul>
 
Something must be outputting something besides headers before this code is run.

Tell me more about your installation....OS, Web server, PHP version, whether you're running PHP as an executable or a module, etc.
 
<paul>
hey ristmo

i tried that little bit of code there with number of different locations and all i got the whole time were black pages.....BUT no errors. so that must some some kind of blind step in the right direction.

I am running Win2kAdvanced Server IIS4+(5 i think) and php4(not sure if its a module or exe or how to tell the difference for that matter) i just installed it from php.net. >>as i post more you will soon learn that most of the stuff i do is by the seat of server:) (or pants)
i have another post in the main php area, which now involves t_variable errors and stuff. i am starting to think the php parser is reeeeeeel picky about stuff....almost eccentric :anyway, any suggestions someone may have are appreciated, someday i hope to return the favor
cheers!
</paul>

--my own little kewl post script >>THIS FORUM ROXXX!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top