Page 1 of 1

header() Cannot modify header information - headers already

Posted: Mon Apr 13, 2009 5:51 am
by lokesh_kumar_s
my website was running fine but now i am having the problem shows

Warning: Cannot modify header information - headers already sent by (output started at /home/content/n/e/l/nelgo1/html/nelgosecurity/secure/nsa/submenucontents.php:3) in /home/content/n/e/l/nelgo1/html/nelgosecurity/secure/nsa/submenucontents.php on line 22

where in line no 22 i see

header("Location: http://www.xxx.com/xxx/xxx.php");

please specify me a solution

Re: header() Cannot modify header information - headers already

Posted: Mon Apr 13, 2009 6:29 am
by requinix
You can't echo or print anything before you call header(). So fix the code so that doesn't happen.

Re: header() Cannot modify header information - headers already

Posted: Mon Apr 13, 2009 6:31 am
by susrisha
you must have had an echo or print statement in line 3 of the same file which resulted in this error.

Re: header() Cannot modify header information - headers already

Posted: Mon Apr 13, 2009 5:59 pm
by Burton333
I had a similar problem on one of my websites. Try to throw this code into it:

Code: Select all

if(headers_sent($file, $line)){
// ... where were the mysterious headers sent from?
echo "Headers were already sent in $file on line $line...";
}
This will tell you where in your code the headers were already sent from and what line it was on. Hope this helps.