Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / September 2005



Tip: Looking for answers? Try searching our database.

Highscore display inside flash game using php and MYSQL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ChuckyLeFrek - 26 Sep 2005 17:15 GMT
I am trying to create a top ten highscore table inside my flash game using PHP
and MYSQL.

My problem is I am not sure how to get the data into Flash.

My database is called "mkhighscores"
The table is called "highscores_tb"

The fields are as follows:

id INT NOT NULL AUTO INCREMENT PRIMARY
game_id INT(4) NOT NULL
name VARCHAR(15) NOT NULL
score INT(15) NOT NULL

I have set the database up so it will hold highscores for more than one game
hence the game_id field

I am not sure how the PHP file will send the required data to Flash

I have read alot of tutorials today and realise that Flash must use the load
command to call the PHP page

e.g LoadObj.load("http://www.blahblah.com/highscores.php?game_id=2)

This will call the PHP page. I guess the PHP page will run a query but how
does it return the results to Flash?

And what format are the results returned to Flash?

Apologies if this is a bit muddled but I am trying to get to grips with a few
technologies at once. I do not want to use an off the shelf solution hence I am
trying to work it all out (with your help)

Thanks

Paul
ChuckyLeFrek - 26 Sep 2005 18:20 GMT
This may make things clearer

Here is my PHP code (I have replaced the username and password for obvious
reasons)

<?php
echo "<center>";
// set your infomation.
$dbhost='localhost';
$dbusername='username';
$dbuserpass='password';
$dbname='mkhighscores';

// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);

if (!mysql_select_db($dbname))
die(mysql_error());

$game = $_GET['game'];
$query = " SELECT game_id,name,score FROM highscores_tb WHERE game_id =
'$game' " .
" ORDER BY score DESC LIMIT 0, 10";
$result = mysql_query($query) or die('Error, query failed');

echo $result;

?>

From my Flash movie I have the following code:

Loaded_txt.text = "Loading";

LoadVarsObj = new LoadVars();

LoadVarsObj.onLoad = function() {
    Loaded_txt.text = "Loaded";
   
}

LoadVarsObj.load("http://www.mediakitchen.co.uk/highscore2.php?game=1");

Basically I was hoping the above would result in my flash movie receiving the
top ten scores in some form or other.

Any help would be really appreciated

Paul
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.