header() Cannot modify header information - headers already

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lokesh_kumar_s
Forum Commoner
Posts: 48
Joined: Mon Apr 13, 2009 5:39 am
Contact:

header() Cannot modify header information - headers already

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post by requinix »

You can't echo or print anything before you call header(). So fix the code so that doesn't happen.
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

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

Post by susrisha »

you must have had an echo or print statement in line 3 of the same file which resulted in this error.
Burton333
Forum Newbie
Posts: 15
Joined: Wed Apr 01, 2009 7:04 pm

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

Post 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.
Post Reply