header(location) [solved]

C++, C#, Java, PHP, ect...
Post Reply
User avatar
havoknz
Posts: 23
Joined: Sun Apr 24, 2011 2:14 am

header(location) [solved]

Post by havoknz »

Hi

me server is giving me this warning
stupid server wrote:Warning: Cannot modify header information - headers already sent by xxxx
im changing it with header(location:"index.php")

Anyone with some php knowledge can you help me?
ConceptDestiny
Posts: 261
Joined: Wed Apr 28, 2010 8:35 am

Re: header(location)

Post by ConceptDestiny »

havoknz wrote:Hi

me server is giving me this warning
stupid server wrote:Warning: Cannot modify header information - headers already sent by xxxx
im changing it with header(location:"index.php")

Anyone with some php knowledge can you help me?
Do you have any includes in your page? (i.e. other pages included which also feature a header) If so, you may be sending multiple headers.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: header(location)

Post by hallsofvallhalla »

you probably have a space in your top line or something above the header line
User avatar
havoknz
Posts: 23
Joined: Sun Apr 24, 2011 2:14 am

Re: header(location)

Post by havoknz »

Why I asked is because it works fine on my wamp localhost but I loaded it up to my godaddy account and now it is giving me that.

Ill look at the white space issue.

I have one include that is initalizeall which loads up all of my included files. Lots of white space in that file...

I have made it into a function called redirect_to("$location") which parses the info into the header(location: "$location").

I thought it might be to do with the server settings...
Xaleph
Posts: 897
Joined: Mon Feb 07, 2011 2:55 am

Re: header(location)

Post by Xaleph »

It has nothing to do with the header(); in PHP.

That error is given when output is already being flushed to the browser while PHP is not ready parsing the page. So you could kind of consider this, the value of $output is already being sent back as output to the browser while $output still has no value set to it. ( i`m not saying that`s your particular problem, but it illustrates the problem )

It means you have unfinished business you should clear before output should be sent. This usually means, like Halls mentioned, some whitespace somewhere.

difference:
<?php // has a space before opening bracket ( meaning output is already being sent to the browser )
<?php // means, first do PHP before anything else
User avatar
havoknz
Posts: 23
Joined: Sun Apr 24, 2011 2:14 am

Re: header(location)

Post by havoknz »

Thanks everyone.

Yeah I think I got it now..

Its all working so :) :)
Post Reply

Return to “Coding”