Page 1 of 1

FLASH to PHP to SQL

Posted: Tue Nov 17, 2009 9:23 pm
by ThatsFishing
Hi there
:banghead:
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);
        }
    }
}
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

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);
?>
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)

Re: FLASH to PHP to SQL

Posted: Wed Nov 18, 2009 9:01 am
by akuji36
Hello

Follow this link:

http://www.devx.com/webdev/Article/36748

It contains an article which shows how to use

Flash Vars -- & sending these variables to php.

Sample files included.

thanks

Rod

:D

Re: FLASH to PHP to SQL

Posted: Wed Nov 18, 2009 12:58 pm
by superdezign
Your could try using a GET request, which requires no more than writing the URL with the query string, and specifying that the request is a GET request.

Re: FLASH to PHP to SQL

Posted: Wed Nov 18, 2009 4:56 pm
by ThatsFishing
ah dear this is so painful. I tried switching to GET and nothing happens either.
And I made sure that my variables had their types embedded (e.g. formPost.user.text)
But no results still.
If I go to the php page in the browser I get

Notice: Undefined index: user in [web address] on line 3 4 and 5
Those are the $_GET lines for the data variables so I'm assuming it shows that error because it has no submitted information to "get"

It must be something simple I'm missing here because it all seems like the code makes sense.

Re: FLASH to PHP to SQL

Posted: Sun Nov 22, 2009 6:27 pm
by ThatsFishing
what other information do I need to give you to help make this easier to solve?