I updated the LeaderboardExample PHP code to replace the MySQL methods with MySQLi methods. The MySQL methods are no longer supported in the latest versions of PHP, which caused warning and error messages to display in the generated JSON file containing the score data. This caused the Leaderboard page to fail to display. Many of the MySQLi methods are the same, except they take the connection object as a parameter. Other methods like error, results, and fetch array use the exact same parameters, so the change was just simply adding the letter ‘i’.
The .htaccess file has now been checked into the repository, which didn’t appear to be checked in before. This file converts the TopScoresAllJSON.php file to the JSON extension, which is consumed by the DisplayScores.html file to display the scores for all of the games.
This code is currently being used in a few of my games such as Fifty Flags. It gives an example Unity project, which shows how to use the leaderboard methods. It also shows how to retrieve scores to be displayed in the game. A MySQL script is provided, to setup the initial score tables. PHP files are provided, which are called by the game code to add new scores and return the leaderboard values. The game identifier must be a unique integer for each game. The unique key must be generated and inserted into both the game code and on the PHP server code.
Download LeaderboardExample Code
See the LeaderboardExample project on my GitHub – https://github.com/gatechgrad/LeaderboardExample