online highscore table

BlitzMax Forums/BlitzMax Programming/online highscore table

ckob(Posted 2006) [#1]
I would like to add one to my games and have it viewable on my website, but I suck at php and have no clue how to go about doing it. Could someone point me to a tutorial or the right direction.


xlsior(Posted 2006) [#2]
Do a search for 'Etna', it will allow you to do exactly that.


ckob(Posted 2006) [#3]
on google or blitzmax forums? Both came up with nothing relevent


Perturbatio(Posted 2006) [#4]
http://www.blitzbasic.com/Community/posts.php?topic=58946
http://www.google.co.uk/search?hl=en&safe=off&q=Etna+site%3Ablitzbasic.com+blitzmax&btnG=Search&meta=


RepeatUntil(Posted 2006) [#5]
Or just click on my signature ;-)


The Caffeine Kid(Posted 2006) [#6]
Is there a cross-platform solution for this?


TartanTangerine (was Indiepath)(Posted 2006) [#7]
iNet source is now free so you could convert it to BMAX code and use it across all platforms. http://indiegamebusiness.com/gamedev.inet.php


Helios(Posted 2006) [#8]
This may or may not be of any use to you, its a simple high score table I wrote for one of my projects (it was quick and hack like so don't expect anything major, its pretty basic and lacks security ... badly), just upload to your server and send a HTTP request via a socket (Look at the GNet source code in the archives or use google if you don't know how to do this) to your server every time you want to check or update it.

<?

/* **************************************************************************
	File: HighScore.php
	Site: BinaryPhoenix.com
	Description: Allows the user to preform several basic high-score actions
				 such as send and retrieving high score results.
   ************************************************************************** */

// Stores global variables describing how to process this request.
$Action   		= $_GET["action"];
$Game     		= $_GET["game"];
$Name     		= $_GET["name"];
$Score    		= $_GET["score"];
$HighScoreCount		= $_GET["count"];
$DatabaseHost 		= "localhost";
$DatabaseName 		= "-=Your database name here=-";
$DatabaseUsername 	= "-=Your database username here=-";
$DatabasePassword 	= "-=Your database password here=-";

// Connect to the database.
if (!mysql_connect($DatabaseHost,$DatabaseUsername,$DatabasePassword)) die("Unable to connect to database");
if (!mysql_select_db($DatabaseName)) die("Unable to select database");

// Preform action.
switch($Action)
{
	case "exists":
	
		// Check values are valid.
		if ($Game == "" || $Name == "") Die("Invalid data.");
		
		// Check for value and return true or false if it exists.
		$Result = mysql_query("SELECT * FROM Scores WHERE Game='" . $Game . "' AND Name='" . $Name . "'");
		if (mysql_num_rows($Result) > 0)
			echo("1");
		else
			echo("0");
		
		break;

	case "send":
	
		// Check values are valid.
		if ($Game == "" || $Name == "" || $Score == "") Die("Invalid data.");
	
		// Add score to database.
		mysql_query("INSERT INTO Scores VALUES ('','" . $Name . "','" . $Score . "','" . $Game . "')");

		break;
		
	case "retrieve":

		// Check values are valid.
		if ($Game == "" || $HighScoreCount == "") Die("Invalid data.");

		// Retrieve value from database.
		$Result = mysql_query("SELECT * FROM Scores WHERE Game='" . $Game . "' ORDER BY Score DESC LIMIT " . $HighScoreCount);
		
		// Echo out the high scores.
		for ($index = 0; $index < mysql_num_rows($Result); $index++) 
		{
			$EntryData = mysql_fetch_assoc($Result);
			echo( $EntryData["Name"] . "=" . $EntryData["Score"] . "\n");
		}
	
		break;
		
	case "view":
	
		// Check values are valid.
		if ($Game == "") Die("Invalid data.");
		
		// Retrieve value from database.
		$Result = mysql_query("SELECT * FROM Scores WHERE Game='" . $Game . "' ORDER BY Score DESC");
		
		// Echo out the high scores.
		for ($index = 0; $index < mysql_numrows($Result); $index++) 
		{
			$EntryData = mysql_fetch_assoc($Result);
			echo( $EntryData["Name"] . "=" . $EntryData["Score"] . "<br/>");
		}
	
		break;
		
	default:
	
		Die("Invalid operation");
		
		break;
		
}

// Close connection to database.
mysql_close();
	
?>