FLASH to PHP to SQL
Posted: Tue Nov 17, 2009 9:23 pm
Hi there
My brain hurts
I've been trying to code my flash game to send its variables to PHP so I can then put them in to mySQL
I think my code must be missing something crucial- I've worked it out as best I can but it still doesn't want to send the variables through
ACTIONSCRIPT
English translation: If the name is not "Type your name here" then create the formPost variable / variable container. - containing the variables set up as User, Score and Email. Send these variables to the php reader page - Then go to and Stop on the "Score submitted frame"
this is the PHP here
English translation: Get the user / score / email posted to the php file from the flash file -
Set up the database and select the table
Insert into the relevant columns the posted data.
End.
(I have some fake data in my table and have managed to set up the flash file to read the sql but I can't get the submittal to work)
My brain hurts
I've been trying to code my flash game to send its variables to PHP so I can then put them in to mySQL
I think my code must be missing something crucial- I've worked it out as best I can but it still doesn't want to send the variables through
ACTIONSCRIPT
Code: Select all
on (release) {
if (_root.user != "Type your name here" && _root.email != "Type your email here") {
var formPost = new LoadVars();
formPost.user = _root.user;
formPost.score = _root.score;
formPost.email = _root.email;
formPost.sendAndLoad(" (php website) ","POST");
gotoAndStop(5);
}
}
}this is the PHP here
Code: Select all
<?
$user= $_POST['formpost.user'];
$score= $_POST['formpost.score'];
$email= $_POST['formpost.email'];
$db= mysql_connect(" ( database) ", "user", "password");
mysql_select_db("table name",$db);
$result = mysql_query("INSERT INTO tff_fishfrenzyscores (user,score,email) VALUES ($user,$score,$email)",$db);
?>Set up the database and select the table
Insert into the relevant columns the posted data.
End.
(I have some fake data in my table and have managed to set up the flash file to read the sql but I can't get the submittal to work)