Adding extra information to Server Side Highscores

Good Evening :-)

I have been struggling with the Server Side Highscores example on the unify community wiki for a good two weeks now, and I really, really need to get this working. The script works excellent, everything is fine and I'm loving it. The problems starts when I try to add additional information to the database.

The thing is, I would like to add two things to the database; the users email address and the date when the score was posted. But whenever I try to update the scripts to support this it wont upload to the database anymore. I have update the HSController, the addscores.php and the MySQL tables but I must be doing something wrong somewhere.

Could you maybe help me out in adding these fields to the script? It would be very much appreciated and you will of course be credited for helping :-)

http://www.unifycommunity.com/wiki/index.php?title=Server_Side_Highscores

You will of course add your extra info in the client script, on this line:

 var highscore_url = addScoreUrl + "name=" + WWW.EscapeURL(name) + "&score=" + score + "&hash=" + hash + "&extra_stuff="+extra_stuff

Then you need to add to the PHP script:

$extra_stuff = mysql_real_escape_string($_GET['extra_stuff'], $db);   

  $query = "insert into scores values (NULL, '$name', '$score', $extra_stuff);"; 

And make sure you add fields to your database too.

You can test your PHP by just hitting it with a web browser.

Allright, I finally got this working. I'll post the full code here so that others can benefit from this in the future

PHP:

<?php 
        $db = mysql_connect('mysql.host.com', 'username', 'password') or die('Could not connect: ' . mysql_error()); 
        mysql_select_db('database') or die('Could not select database');

        // Strings must be escaped to prevent SQL injection attack. 
        $name = mysql_real_escape_string($_GET['name'], $db); 
        $score = mysql_real_escape_string($_GET['score'], $db);
        $email = mysql_real_escape_string($_GET['email'], $db); 
        $date = date("d/m/Y");
        $hash = $_GET['hash']; 

        $secretKey="replacewithyourown"; # Change this value to match the value stored in the client javascript below 

        $real_hash = md5($name . $score . $secretKey); 

        if ($real_hash != $hash) {
        die('haha, try again sucker');  
        }

        if($real_hash == $hash) { 
            // Send variables for the MySQL database class. 
            $query = "insert into scores values (NULL, '$name', '$score', '$email', '$date');"; 
            $result = mysql_query($query) or die('Query failed: ' . mysql_error()); 
        } 
?>

Javascript:

private var secretKey="replacewithyourown"; // Edit this value and make sure it's the same as the one stored on the server
var addScoreUrl="http://replacewithyourown.com/addscore.php?"; //be sure to add a ? to your url
var highscoreUrl="http://replacewithyourown.com/display.php";    

function postScore(name, score, email) {
    //This connects to a server side php script that will add the name and score to a MySQL DB.
    // Supply it with a string representing the players name and the players score.
   var hash=md5functions.Md5Sum(name + score + secretKey);

   var highscore_url = addScoreUrl + "name=" + WWW.EscapeURL(name) + "&score=" + score + "&email=" + WWW.EscapeURL(email) + "&hash=" + hash ;

    // Post the URL to the site and create a download object to get the result.
    hs_post = WWW(highscore_url);
    yield hs_post; // Wait until the download is done
    if(hs_post.error) {
        print("There was an error posting the high score: " + hs_post.error);
    }
}

// Get the scores from the MySQL DB to display in a GUIText.
function getScores() {
    gameObject.guiText.text = "Loading Scores";
    hs_get = WWW(highscoreUrl);
    yield hs_get;

    if(hs_get.error) {
        print("There was an error getting the high score: " + hs_get.error);
    } else {
        gameObject.guiText.text = hs_get.data; // this is a GUIText that will display the scores in game.
    }
}

MySQL Table:

CREATE TABLE `scores` (
   `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
   `name` varchar(15) NOT NULL DEFAULT 'anonymous',
   `score` int(10) UNSIGNED NOT NULL DEFAULT '0' ,
   `email` varchar(255) NOT NULL DEFAULT 'anonymous',
   `date` varchar(15) NOT NULL DEFAULT 'anonymous'

Assets/all/score/score.js(36,13): BCE0005: Unknown identifier: 'Md5'. error how can souve?

I have set up the db and its working with Server Side Highscores script. i am getting stuck in adding data automatically eg when a coin is collected in a game a score is added live onto the sql . any suggestions ?