peter5
12-04-2005, 09:48 PM
Hi all, I have been googling and searching the forums for hours, and have not come up with anything that tells me concisely what I should do.
Below is my PHP code, I have no Flash code yet as I cannot figure out what to do. I think it has something to do with loadVars(), however the macromedia online documentation is unhelpful, and all the forums seem to be about passing data to php, I am wanting to get it from php.
I want to return 13 variables from my php code, and then use them in my flash code. Any help,code snippets, or tutorial pointers would be extremely welcome.
<?
//Open Databaseconnection
$objconn = mysql_connect($mySQLserver, $mySQLUID, $mySQLpass);
if (!$objconn)
{
die('Could not connect: ' . mysql_error());
}
$objconnDB = mysql_select_db($mySQLDatabase,$objconn);
if(!$objconnDB)
{
die('Could not open' . $mySQLDatabase . mysql_error());
}
$level = "1";
$row_query = mysql_query(" SELECT * FROM `quiz` WHERE level=".$level." ORDER BY RAND() LIMIT 1");
$row = mysql_fetch_array($row_query);
//break the row into the various variables
$tQuestion = $row["question"];
$tAnswerA = $row["answerA"];
$tAnswerB = $row["answerB"];
$tAnswerC = $row["answerC"];
$tAnswerD = $row["answerD"];
$tCorrect = $row["correct"];
$tAudienceA = $row["audienceA"];
$tAudienceB = $row["audienceB"];
$tAudienceC = $row["audienceC"];
$tAudienceD = $row["audienceD"];
$tFriendname = $row["friend_name"];
$tFriend1 = $row["friend1"];
$tFriend2 = $row["friend2"];
//Close Database
mysql_close($objconn);
print "question=".$tQuestion;
?>
Below is my PHP code, I have no Flash code yet as I cannot figure out what to do. I think it has something to do with loadVars(), however the macromedia online documentation is unhelpful, and all the forums seem to be about passing data to php, I am wanting to get it from php.
I want to return 13 variables from my php code, and then use them in my flash code. Any help,code snippets, or tutorial pointers would be extremely welcome.
<?
//Open Databaseconnection
$objconn = mysql_connect($mySQLserver, $mySQLUID, $mySQLpass);
if (!$objconn)
{
die('Could not connect: ' . mysql_error());
}
$objconnDB = mysql_select_db($mySQLDatabase,$objconn);
if(!$objconnDB)
{
die('Could not open' . $mySQLDatabase . mysql_error());
}
$level = "1";
$row_query = mysql_query(" SELECT * FROM `quiz` WHERE level=".$level." ORDER BY RAND() LIMIT 1");
$row = mysql_fetch_array($row_query);
//break the row into the various variables
$tQuestion = $row["question"];
$tAnswerA = $row["answerA"];
$tAnswerB = $row["answerB"];
$tAnswerC = $row["answerC"];
$tAnswerD = $row["answerD"];
$tCorrect = $row["correct"];
$tAudienceA = $row["audienceA"];
$tAudienceB = $row["audienceB"];
$tAudienceC = $row["audienceC"];
$tAudienceD = $row["audienceD"];
$tFriendname = $row["friend_name"];
$tFriend1 = $row["friend1"];
$tFriend2 = $row["friend2"];
//Close Database
mysql_close($objconn);
print "question=".$tQuestion;
?>