- Home /
unity 3D - android platform] problem on server side highscore get method on actual android device.
so i have this android project that implements a simple online leader-board, i used the Server Side high-score from the Unify Community Wiki link text and tried to applied it on an android project.
here is the situation: when i run the project on Unity itself, both the set and get method for the database is working, simply put i can post new scores on to the database server and i can grab the scores from the database server and show it on the Leader-board scene using GUIText.
now when i run the project on an actual Android device e.g. an android tablet or a smart phone, i can surely set new scores to the database server, but somehow the get method won't work on it, i can't seem to show the scores from the server on the leader-board scene when the game is running on an actual device...
its seems like if the game is running on an actual android device, it can write on the server but it can't read, meaning i can post scores but i can't just display them.
but when i run the same game on Unity in PC it can post scores and also display them...
file size for images is limited so I'll just post links on two images:
this one is a picture of the leader-board scene of the game running on an actual android device, see how the scores won't appear but i can post new scores on the server using the device, but it won't display them, post method is working but get is not working... link text
this one is a screenshot of the leader-board scene of the android project running in unity, it displays the score, as well as you can also post new scores on to the database server, both post and get is working. link text
this is the code for my getmethod script:
var getScoreUrl = "ewoogaming.x10host.com/display.php";
function Awake()
{
GetScores();
}
function GetScores()
{
var hs_get = WWW(getScoreUrl);
yield hs_get;
if(hs_get.error)
{
print("Error getting scores: " + hs_get.error);
}
else
{
guiText.text = hs_get.text;
}
}
this is the code for my diplay.php, side note i had to change the user and password for the database and the database name.
<?php
// Send variables for the MySQL database class.
$database = mysql_connect('localhost', 'myUser', 'myPass') or die('Could not connect: ' . mysql_error());
mysql_select_db('myDB') 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";
}
?>
Your answer
Follow this Question
Related Questions
sensor temperature android 0 Answers
whole animation not being played 0 Answers
Unity 3d app make my andorid phone heat 1 Answer
How to run unity app like a "live wallpaper" on android? 0 Answers
Simple Unity3d Facebook Integration? 1 Answer