- Home /
Question by
hbs1215 · Mar 17, 2016 at 08:34 AM ·
androidwwwsqldatabase
WWW form doesn't work only on andriod
I'm making a scoreboard for my game, and I built my server and db.
I'm using this code and it works fine on PC.
IEnumerator PostScores(string name, int score)
{
string hash = Md5Sum(name + score + secretKey);
string post_url = addScoreURL + "name=" + name + "&score=" + score + "&hash=" + hash;
WWW hs_post = new WWW("http://"+post_url);
yield return hs_post;
if (hs_post.error != null)
{
print("There was an error posting the high score: " + hs_post.error);
}
}
And this is my php
<?php
$db = mysql_connect('mysql.hostinger.kr', 'name', 'ps') or die('Could not connect: ' . mysql_error());
mysql_select_db('dbname') or die('Could not select database');
$name = mysql_real_escape_string($_GET['name'], $db);
$score = mysql_real_escape_string($_GET['score'], $db);
$hash = $_GET['hash'];
$secretKey="key";
$real_hash = md5($name . $score . $secretKey);
if($real_hash == $hash) {
$query = "insert into scores values (NULL, '$name', '$score');";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}
?>
On android, my app doesn't upload data to the db.. I don't know why. please help me
Comment
Your answer
