Jump to content

high score in flash game - PhP


hahaitwork

Recommended Posts

hello,I'm in need of getting my high score to work in my game.It won't load the high scores and it wont post the scores :SThis code is from: get_score2.php<?php$db=mysql_connect("loff-production.com.mysql", "loff_production", "Mypassword");mysql_select_db("high_scores", $db);$scores = '';$name = '';$query = "select * from high_scores order by score DESC LIMIT 0,10";$result=mysql_query($query);$i = 0;while($row=mysql_fetch_array($result)){$name .= 'name'.$i.'='.urlencode($row['name']).'&';$scores .= 'score'.$i.'='.urlencode($row['score']).'&';$i++;}echo $scores;echo $name;?>This code is from register.php:<?php$db=mysql_connect("loff-production.com.mysql", "loff_production", "Mypassword");mysql_select_db("high_scores", $db);$sql = 'INSERT INTO high_scores (name,score) VALUES ("'.$_POST['name'].'","'.$_POST['score'].'")';$result = mysql_query ($sql);if ($result) {$created = 'score posted for ' .$_POST ['name'];echo 'message='.urlencode($created);}?>This code is from One of the frames in my flash file:stop();var lowHighScore = 0;myData = new LoadVars();myData.load("get_score2.php");myData.onLoad = function(success){if(success){for(var i=0; i<10; i++){_root["n"+i].text = this['name'+i];_root["s"+i].text = this['score'+i];if(i==9){lowHighScore = s9.text;}}}else{trace("Error loading data!");}}This code is from another frame in my flash file:stop();if(score_txt.text > lowHighScore){message_txt.text = "Congratulations! Submit your initials and high score..."}else{message_txt.text = "You did not get a high score, please try again!";}player = new LoadVars();playerRegistered = new LoadVars();playerRegistered.onLoad = showResult;submit_btn.onRelease = submitScore;function submitScore():Void {player.name = name_txt.text;player.score = score_txt.text;player.sendAndLoad("register.php",playerRegistered);}function showResult():Void {message_txt.text = this.error;message_txt.text = this.message;name_txt.text = "";score_txt.text = "";_root.play();}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...