Hi all…
I finally get the highscore working (the script from the Wiki), but…
From the webpage (display.php) it’s ok, but in Unity it looks like this:
(se below)
“Everything” is displayed…??
Please help!
/errormaker
Hi all…
I finally get the highscore working (the script from the Wiki), but…
From the webpage (display.php) it’s ok, but in Unity it looks like this:
(se below)
“Everything” is displayed…??
Please help!
/errormaker
The php script on the server seems to be returning HTML when run. This is of course fine when viewing it with a web browser.
You should change the php script format the resutls in a simpler way that’s easer to parse by your game code.
Hi
Thax for the replay!
This is the code (from WIKI):
// 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.
}
}
The “highscoreUrl” is from:
var highscoreUrl=“http://xxxxxx.freehost10.com/display.php”;
Shall I change something here?
Or on the server?
As Keli already noted, it’s the PHP script on the server that is returning HTML instead of just a string with your score data. As such the change needs to be made in the PHP script on the server so the information returned is simplified and ready for use in your content.
Hi
I just follow the WIKI “Server Side Highscores”
http://www.unifycommunity.com/wiki/index.php?title=Server_Side_Highscores
I’ts for a Highscores in Unity…
The display.php file:
<?php
// Send variables for the MySQL database class.
$database = mysql_connect('localhost', 'kalle2_bark', 'xxxxxxxx') or die('Could not connect: ' . mysql_error());
mysql_select_db('kalle2_mindatabas') or die('Could not select database');
$query = "SELECT * FROM `scores` ORDER by `score` DESC LIMIT 10";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$num_results = mysql_num_rows($result);
for($i = 0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
echo $row['name'] . "\t" . $row['score'] . "\n";
}
?>
Shall I change something here, or…?
I’am totaly new to php…
Just want a “simple” highscore…
Please help!
From the look of the output you provided, your issue is that your web host is embedding javascript code for metrics collection. This is worthless to you as you’re not executing the code. Figure out how to turn it off and all will be well.
Also, it’s bad forum etiquette to make multiple concurrent topics asking for help on the same issue.
Thank You! I think You have the answer!
I look in to that.
You’re welcome!
From my experience this is a global setting for most web hosts, haven’t seen any exclusions. So just be aware that you’ll lose metrics for your entire website by turning it off.
If you’re using a free host, they might even think your website is dead and turn it off!
Hi!
It’s working!
The soulution: I got an other host!
(byethost24.com, the old: freehost10.com)
Thax again!