Results 1 to 5 of 5
  1. #1
    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?

  2. #2
    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

  3. #3
    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.

  4. #4
    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.

  5. #5
    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.
    maddudemike, please, don't give bad advices if you are not familliar with the matter. What you're suggesting will work but is unnecessary overhead and will make the developer code more.

    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;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •