|
-
Hi, what function in flash are you using to post your scores to the php script?
I generally use:
Code:
loadVariablesNum("urlofscorepostingscript",0, "POST");
And then the following score posting script;
Code:
<?php
$db = mysql_connect("localhost", "username", "password") or die("Could not connect.");
if(!$db)
die("no db");
if(!mysql_select_db("db_name",$db))
die("No database selected.");
if(isset($_POST['score']))
{
$score=$_POST['score'];
$name=$_POST['thename'];
$countscore="SELECT COUNT(*) from asteriodscores";
$countscore2=mysql_query($countscore);
$countscore3=mysql_result($countscore2,0);
if($countscore3<10)
{
$insertscore="INSERT into asteriodscores (score,name) values('$score','$name')";
mysql_query($insertscore) or die("Could not insert score");
print "Score recorded.";
}
else
{
$getlowscore="SELECT * from asteriodscores order by score ASC limit 1";
$getlowscore2=mysql_query($getlowscore) or die("Could not get score");
$getlowscore3=mysql_fetch_array($getlowscore2);
if($score>$getlowscore3[score])
{
$replace="update asteriodscores set score='$score', name='$name' where ID='$getlowscore3[ID]'";
$replace2=mysql_query($replace) or die(mysql_error());
print "Score recorded.";
}
}
}
?>
Last edited by Archbob; 04-03-2006 at 05:44 PM.
-
Amiga freak
Instructions added.
 Originally Posted by Archbob
Hi, what function in flash are you using to post your scores to the php script?
I generally use:
Code:
loadVariablesNum("urlofscorepostingscript",0, "POST");
And then the following score posting script;
Code:
<?php
$db = mysql_connect("localhost", "username", "password") or die("Could not connect.");
........
I use the one on EgoAnt's page..., so I use:
sendScore.sendAndLoad("addScore.php", score_result, "POST")
and
loadVariables("getScores.php", "startGameClip");
using this code in Flash:
Code:
function sendScores(userName:String, userScore:Number) {
var sendScore:LoadVars = new LoadVars();
sendScore.userName = userName;
sendScore.myScore = userScore;
var score_result:LoadVars = new LoadVars();
score_result.onLoad = function(success:Boolean) {
submitScoreClip._visible = false;
startGameClip._visible = true;
setScore(0, 0);
setLife(0, 100);
if (success && this.scoreIn == "1") {
systemText.text = "Score sent!";
} else {
systemText.text = "Error sending score to server.";
trace(this.scoreError);
}
};
and stuff. and some php scripts...
do, what should I do to make it work on a server with register_globals OFF in the PHP.ini??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|