Results 1 to 5 of 5
-
09-20-2005, 06:09 PM #1Web Hosting Master
- Join Date
- Jan 2005
- Location
- UK, London
- Posts
- 764
use the variable stored in the string across another php script
Basically,
on my index.php file, i can select what game i want to play by typing this url
http://www.mysite.com/index.php?game=DTunnel
so, inside the index.php file i have this setup
$gamename = $_GET['game'];
now, i want to use the variable stored in the string $gamename across another php script
the another script is basically called scoreboard.php and i need the variable in the $gamename so i can do a mysql lookup and show all the highscore for the game the user is currently playing, i.e. index.php?game=DTunnel
how do i do this?:: www.AsuraHosting.com ::
-
09-20-2005, 06:58 PM #2Web Hosting Evangelist
- Join Date
- Mar 2004
- Posts
- 502
Is the second script, scoreboard.php, included in the first script? If so, the variable is available to you already. If not, you could set a session variable and pass it between requests that way.
e-Tech-Solution.com: Shared Windows 2003 Hosting and Cross-platform Web Development
-
09-21-2005, 01:47 AM #3Web Hosting Master
- Join Date
- Jan 2005
- Location
- UK, London
- Posts
- 764
lolz... this is so freaky, i jus woke up now at 6.45am wondering, wht if i user sessions and opened the wht was suggested here... amazing
btw, the first page isnt included, so im going to use sessions
thanks for your suggestion TechSolution.:: www.AsuraHosting.com ::
-
09-22-2005, 03:48 AM #4Junior Guru
- Join Date
- Mar 2005
- Posts
- 214
yeah store sessions in your MYSQL database. Then when they goto or get sent to scoreboard.php check their ip match it to a session then check for the gamename in mysql associated with that session.
-
09-22-2005, 06:45 AM #5Web Hosting Evangelist
- Join Date
- Apr 2005
- Posts
- 522
Originally posted by maddudemike
yeah store sessions in your MYSQL database. Then when they goto or get sent to scoreboard.php check their ip match it to a session then check for the gamename in mysql associated with that session.
Sessions are stored in MySQL db in certain circumstances, for instance - when working with clustered servers.
Also, you can specify your own session_save_handler so you don't have to re-write the entire session logic.
Solution to this is just starting a session, setting a session variable and then reading it/comparing values.
Trivial problem with trivial solution. You just need session_start(); and $_SESSION['game'] = $game;