hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : use the variable stored in the string across another php script
Reply

Forum Jump

use the variable stored in the string across another php script

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old
AsuraHosting.Com
 
Join Date: Jan 2005
Location: UK, London
Posts: 762

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 ::



Sponsored Links
  #2  
Old
Web 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

  #3  
Old
AsuraHosting.Com
 
Join Date: Jan 2005
Location: UK, London
Posts: 762
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 ::

Sponsored Links
  #4  
Old
Junior Guru
 
Join Date: Mar 2005
Posts: 211
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  
Old
Web Hosting Evangelist
 
Join Date: Apr 2005
Posts: 521
Quote:
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;

Reply

Related posts from TheWhir.com
Title Type Date Posted
Service Providers Push Updates to Fight OpenSSL Heartbleed Bug Web Hosting News 2014-05-01 08:31:27
Web Hosting Sales and Promos Roundup - December 6, 2013 Web Hosting News 2014-05-23 15:42:37
OpenStack and the AWS API Debate Web Hosting News 2014-05-09 12:40:29
Researchers Urge System Admins to Check for New Apache Web Server Backdoor Malware Web Hosting News 2013-05-01 11:35:53
Pingdom Talks Top Web Hosting Cities and Countries Web Hosting News 2014-05-09 12:40:35


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
WHT Host Brief Email:

We respect your privacy. We will never sell, rent, or give away your address to any outside party, ever.

Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?