PHP header("Location: "); NOT WORKING

Problems with the Linux version of XAMPP, questions, comments, and anything related.

PHP header("Location: "); NOT WORKING

Postby Goce » 31. January 2009 00:16

So I used to use the apache2, mysql, and php5 through SuseLinux.. However last night I upgraded to a newer version of Linux and loaded on XAMPP to do my web serving.. Everything seemed to work after a bit of tweeking, except for my flash games area.. It uses a page for game count then the code:

header("Location: flashgamesplay.php?gamename=game_name&cat=action")

But it just counts the game as a play and will not show the game.. It's the header("location: "); that's not sending it to the game now.. How can I fix this or is there a work around? Perhaps it's a setting somewhere? no? I just don't know but I need my site back up ASAP please! Thank you all!
Goce
 
Posts: 8
Joined: 31. January 2009 00:10

Re: PHP header("Location: "); NOT WORKING

Postby Wiedmann » 31. January 2009 01:04

It's the header("location: "); that's not sending it to the game now..

What happens instead?
- it send you to another location?
- enable debug/error output in your script and look for an error message.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: PHP header("Location: "); NOT WORKING

Postby Goce » 31. January 2009 01:16

well this is my setup...

I have a php file called from my web site...
In that file it adds +1 to the play counter.. Then in the same file I have the header command to go to the next file..
In the next file it loads the game to be played..

I have this like this cause if I just have the same page count and load game, for some reason it adds +2 to the counter..

The ONLY way I know how to make this setup workie is to use header("location: file.php");
Goce
 
Posts: 8
Joined: 31. January 2009 00:10

Re: PHP header("Location: "); NOT WORKING

Postby Wiedmann » 31. January 2009 12:03

Then in the same file I have the header command to go to the next file..

And what happens exactly if the code reach this header() function?
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: PHP header("Location: "); NOT WORKING

Postby Goce » 31. January 2009 13:49

It stays on the count page.. I added <?php error_reporting(E_ALL); ?> to the start of the page and I get this...


Notice: Undefined variable: null in /opt/lampp/htdocs/vrgs/flashgames/flashgamecnt.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/vrgs/flashgames/flashgamecnt.php:26) in /opt/lampp/htdocs/vrgs/flashgames/flashgamecnt.php on line 93
Goce
 
Posts: 8
Joined: 31. January 2009 00:10

Re: PHP header("Location: "); NOT WORKING

Postby Wiedmann » 31. January 2009 14:06

Warning: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/vrgs/flashgames/flashgamecnt.php:26) in /opt/lampp/htdocs/vrgs/flashgames/flashgamecnt.php on line 93

I guess that's the problem. If there was already a output, a header() function can't work. (see the manual page for header().)

(For such "ugly" coding, a quirk can be to enable output buffering.)
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: PHP header("Location: "); NOT WORKING

Postby Goce » 31. January 2009 14:49

Then why the hell did it work before I switched up to XAMPP then? I just don't understand.. There must be a setting somewhere that is different, right?
Goce
 
Posts: 8
Joined: 31. January 2009 00:10

Re: PHP header("Location: "); NOT WORKING

Postby Wiedmann » 31. January 2009 19:25

There must be a setting somewhere that is different, right?

Read my last sentence.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: PHP header("Location: "); NOT WORKING

Postby Goce » 02. February 2009 21:54

I see... well I just cut all the protection out and it works fine now... ty for your help though..
Goce
 
Posts: 8
Joined: 31. January 2009 00:10

Re: PHP header("Location: "); NOT WORKING

Postby kchirag » 17. October 2009 01:53

Disable this in php.ini
output_buffering = On

-Chirag
kchirag
 
Posts: 1
Joined: 17. October 2009 01:49


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 31 guests