5
ho bisogno di salvare i punteggi più alti di un gioco in Flash utilizzando PHP/MySQL, ma non funzionaSalva Gioco Flash I punteggi PHP/MySQL
Ecco il codice:
AS3
ActionScript:
var myrequest:URLRequest = new URLRequest("score.php");
myrequest.method = URLRequestMethod.POST;
var variables:URLVariables = new URLVariables();
variables.name = nombrem;
variables.score = puntosJugador;
myrequest.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, dataOnLoad);
loader.load(myrequest);
PHP
//Include database connection details
require_once('config.php');
//Connect to mysql server
$link = mysql_connect([b]**HOST**, **USERNAME**, **PASSWORD**[/b]D);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(**DATABASENA**);
if(!$db) {
die("Unable to select database");
}
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$name = clean($_POST['username']);
$score = clean($_POST['score']);
$currentdate = date("Y/m/d");
//Create INSERT query
$qry = "INSERT INTO highscores(user,time,date) VALUES('$name','$score','$currentdate')";
$result = @mysql_query($qry);
echo "writing=Ok";
exit();
mysql_close();
?>
e ho creato una tabella su MySQL denominata 'highscores' con nomi 'utente', 'ora' e 'data'
qualsiasi aiuto per favore?
quindi devo capirlo ($ _POST ['nome']) ?? –
si si ... – tanaydin