faqts : Computers : Programming : Languages : PHP : Common Problems : HTTP Headers

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

29 of 76 people (38%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

I get this error: "Cannot add header information - headers already sent by ..."

Jan 24th, 2005 23:56
Thadeus Joseph, Virgilio Cantu, Rick Jolly,


change your code to:
<?
ob_start();
page contents
and then you can use the header function from anywhere in your file to 
redirect. This will not generate any errors.
Headers must be sent before anything else. Be sure you don't even have 
spaces before <?php and after ?> tags. You can use the headers_sent 
function to test whether it's safe to send more headers. Also check 
output buffering functions in PHP manual for advanced applications.