joebudden Posted February 23, 2007 Share Posted February 23, 2007 Hi guys , is anyone familiar with getting PHP variables into FLASH? I have so far managed to get normal variables into flash with no problem i.e. $var = "var"; However, I am building a game, where all of the queries to get the required information from mySQL use session variables ... $gameid and $teamid .. which are generated at random and assigned to session variables.. The problem is that flash cant get at these variables.. and thus the queries fail.. I know most people on here just specialise in PHP but I fort I would ask coz the Flash forums are useless.. If anyone here is familiar with using PHP in FLASH drop me a post, coz i desperately need the help cheers dudes Link to comment https://forums.phpfreaks.com/topic/39722-php-session-variables-in-flash/ Share on other sites More sharing options...
corbin Posted February 23, 2007 Share Posted February 23, 2007 You can have flash read the PHP file passing the PHP file the correct variables. Then make PHP return the session variables. You could even send the flash thing the entire session array.... I would post code, but I don't have Flash on this computer, and it's fairly simple so I don't feel code is needed. Link to comment https://forums.phpfreaks.com/topic/39722-php-session-variables-in-flash/#findComment-191777 Share on other sites More sharing options...
joebudden Posted February 23, 2007 Author Share Posted February 23, 2007 hey dude... well heres the way im doing it... PHP <?php //connect to database include("connect.php"); $randquery = "SELECT playersurname FROM player ORDER BY RAND() LIMIT 1"; $randomplayer = mysql_query($randquery) or die(mysql_error()); $row = mysql_fetch_assoc($randomplayer); $team1 ="team1"; $team2 ="team2"; $randplayer = $row['playersurname']; echo "&team1=".urlencode($team1); echo "&team2=".urlencode($team2); echo "&randplayer=".urlencode($randplayer); ?> AS /* first create a new instance of the LoadVars object */ myVars = new LoadVars(); // call the load method to load my php page myVars.load("http://localhost:6789/pp33tt/PHP_footbal_manager_with_flash/flash3.php"); myVars.team1; myVars.team2; myVars.randplayer; myVars.onLoad = function (success) { if (success) { team1.text = myVars.team1; team2.text = myVars.team2; randplayer.text = myVars.randplayer; trace (" variables loaded "); for( var test in this ) { trace (" key " + test + " = " + this[test]); } } else { trace (" Error loading variables "); } } this gets the variables fine... but like i say i wana use session variables in my queries... can u remember what ya need to do ??? Link to comment https://forums.phpfreaks.com/topic/39722-php-session-variables-in-flash/#findComment-191782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.