vphmubkc Posted July 9, 2005 Posted July 9, 2005 I get the following error when trying to do some simple HTTP authentication in a PHP script. I've never seen this before, and I can't find anything about it in the PHP manual. Any help would be appreciated. Thanks. Warning: Cannot modify header information - headers already sent by (output started at /home/vphmubkc/public_html/timesheet/index.php:18) in /home/vphmubkc/public_html/timesheet/index.php on line 30 Quote
TCH-Rob Posted July 9, 2005 Posted July 9, 2005 Nevermind, Davids answer was better sounding than mine. Quote
TweezerMan Posted July 9, 2005 Posted July 9, 2005 Welcome to the forums, vphmubkc! At line 18 in your script, there is some statement that is sending actual content to the browser (echo, print, content or HTML outside of <?php ... ?> tags, etc.). This triggers all HTTP headers to be automatically sent, as the HTTP headers must all be sent before any content or HTML is sent to the browser. At line 30 of your script, there is a function that is trying to add or modify the HTTP headers (probably header() ). Since all HTTP headers were already sent to the browser at line 18 of your script (along with whatever content or HTML was output), the HTTP headers can no longer be added to or modified, and this triggers the PHP error message you're seeing. Hope this helps... Quote
TCH-Don Posted July 9, 2005 Posted July 9, 2005 Welcome to the forums vphmubkc I have done the same thing by just having a space at the head of a script bfore going into php. Quote
TweezerMan Posted July 9, 2005 Posted July 9, 2005 Nevermind, Davids answer was better sounding than mine. <{POST_SNAPBACK}> Sorry! I get the following error when trying to do some simple HTTP authentication in a PHP script. I've never seen this before, and I can't find anything about it in the PHP manual. <{POST_SNAPBACK}> I found this FAQ in the PHP manual that is probably most applicable to your issue: 6. I get the message 'Warning: Cannot send session cookie - headers already sent...' or 'Cannot add header information - headers already sent...'. The functions header(), setcookie(), and the session functions need to add headers to the output stream but headers can only be sent before all other content. There can be no output before using these functions, output such as HTML. The function headers_sent() will check if your script has already sent headers and see also the Output Control functions. Even though your error is 'Cannot modify header information' rather than 'Cannot add header information', this FAQ answer is still applicable. I have done the same thing by just having a space at the head of a script bfore going into php.<{POST_SNAPBACK}> It could be simply a blank line or space, but whatever it is, it's at line 18, rather than at the beginning or end of the script. A couple of examples of what could cause this error: >17: ?> 18: 19: <?php >18: ?> <?php Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.