It doesnt save the hiscore to the mysql database. When the flash file is stored on my harddrive this works perfectly but when i upload the file on my main site the hiscore doesnt update. I started with flash yesterday so im not that capable of problem solving i guess.
I started from this code
http://www.sonsoftco.com/flash-devel...-tutorial.html
but ended with
AS3
Actionscript Code:
function submitted()
{
var myrequest:URLRequest = new URLRequest("http://hiscore.rudebeckselevrad.se/sendscore.php");
myrequest.method = URLRequestMethod.POST;
var variables:URLVariables = new URLVariables();
variables.username = nametext.text;
variables.score = win;
myrequest.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, dataOnLoad);
loader.load(myrequest);
}
This is my php code
PHP Code:
<?php
//Include database connection details
require_once('config.php');
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
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();
?>