FLASH to PHP to SQL

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
ThatsFishing
Forum Newbie
Posts: 3
Joined: Tue Nov 17, 2009 9:09 pm

FLASH to PHP to SQL

Post 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)
User avatar
akuji36
Forum Contributor
Posts: 190
Joined: Tue Oct 14, 2008 9:53 am
Location: Hartford, Connecticut

Re: FLASH to PHP to SQL

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: FLASH to PHP to SQL

Post 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.
User avatar
ThatsFishing
Forum Newbie
Posts: 3
Joined: Tue Nov 17, 2009 9:09 pm

Re: FLASH to PHP to SQL

Post 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.
User avatar
ThatsFishing
Forum Newbie
Posts: 3
Joined: Tue Nov 17, 2009 9:09 pm

Re: FLASH to PHP to SQL

Post by ThatsFishing »

what other information do I need to give you to help make this easier to solve?
Post Reply