Redirection: header("Location: ") doesnot work in

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
bikram99
Forum Newbie
Posts: 2
Joined: Wed Jan 04, 2006 2:56 am
Location: Nepal
Contact:

Redirection: header("Location: ") doesnot work in

Post by bikram99 »

In localhost I'm using EasyPHP1.7. To redirect the browser following code:

Code: Select all

header("Location: somewhere")
does work. But when I deploy the same code over remote site following error is generated.
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/webhome/nwpweb/haatbazar/haatbazar/controlcenter/index.php:2) in /var/www/html/webhome/nwpweb/haatbazar/haatbazar/controlcenter/index.php on line 25
Please help me out.

Bikram
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post by djot »

-
This is a common error that occurs when using session, cookies or headers. The message states that output already started and therefor no header information could be send anymore. So what's wrong? You have some output in front of your header line.

Check your file to

1. have <?php in line 0, being the first signs (so no empty lines or spaces before)
2. not have things like <?php...?> <?php...?> (spaces or html output)
3. ?> being the last 2chars in your files, so no line break or space behind.


If you find nothing in the current file, also check files you perhaps included before.


djot
-
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

In simple words there should be no spaces and html code before header function
Cheers :D
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

viewtopic.php?t=1157

I've lost count and don't care to figure out what the last count was... :roll:
bikram99
Forum Newbie
Posts: 2
Joined: Wed Jan 04, 2006 2:56 am
Location: Nepal
Contact:

Post by bikram99 »

Everybody,

Thank you very much for replying and answering my query. I'll track my code according to the suggestions.

But now, my question is "Why does this still work while working in EasyPHP-7?"

Thank you Again
Bikram
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

bikram99 wrote: But now, my question is "Why does this still work while working in EasyPHP-7?"
I don't have a clue what EasyPHP-7 is, but i'm pretty sure the answer is the following: It buffers the output (you'll find more about this in the threads you find when you follow feyds link)
Post Reply