String looks like 8. But I cant convert it to number. Code:
public void UpdCoins(string str)
{
Write ("strCoins="+str+" uid="+UserId+" next ch ");
Write ("="+str+"=");// returns =8=
Write (("8"==str[0].ToString()).ToString());// returns False
// declare a string variable with a value that represents a valid integer
string sillyMeme = str;
int memeValue;
// attempt to parse the value using the TryParse functionality of the integer type
int.TryParse(sillyMeme, out memeValue);
Write(memeValue.ToString());//9001
SocialData[UserId].Coins = memeValue;
Write ("RESULT Coins="+SocialData[UserId].Coins.ToString()+" uid="+UserId);
}
public static void Write(string mes)
{
Application.ExternalCall ("Alert", mes);
//LogClass.Mess += mes + " ";
Debug.Log ("SM->" + mes);
}
This pieces are in SocialManager.cs
Now piece from index.html of game
function GetCoins() {
alert(viewer_id + "do");
SendToPlayer("UpdCoins", '<?php include 'output.php'; ?>');
}
function SendToPlayer(func, what){
gameInstance.SendMessage("SocialManager",func,what);
}
And now the full php
<?php
include 'db.php';
$stmt = $pdo->prepare('SELECT * FROM payments WHERE users="372380032"');
$stmt->execute();
$data = $stmt->fetchAll();
$result = $data[0]['coins'];
$pdo = null;
echo $result.'';
?>
Why “8” cant convert to 8? Returns format error