Unity不会更改SQL数据库值

时间:2017-02-05 18:09:03

标签: c# php

我的服务器上有这个php,当我点击一个按钮添加货币时,它被调用运行:

// Select player_name
$check = mysqli_query($conn,"select Currency from player where Name='$player_name'");
$checkrows=mysqli_num_rows($check);

if($checkrows==1) {
    $sql = "INSERT INTO player (Currency) VALUES ('post_player_currency')";
    $result = mysqli_query($conn, $sql) or die('Error querying database.');
    echo ("DATABASE: Currency added ");
} else { 
// Insert player into database
    echo "DATABASE: Currency NOT added ";
}
?>

在我的Unity C#脚本上,我有这个:

public IEnumerator AddCurrency(Text playername, Text playercurrency) {
    _tempCoins = int.Parse(coins.text);
    _tempCoins += 10;
    coins.text = _tempCoins.ToString();


    WWWForm form = new WWWForm ();
    form.AddField ("post_player_name", playername.text);
    form.AddField ("post_player_currency", playercurrency.text);

    WWW www = new WWW (RegisterPlayerURL, form);
    yield return www;
    print (www.text);

    if (www.text == "DATABASE: Currency added ") {
        print ("TRANSACTION: Current Coins: " + _tempCoins);
    }
}

脚本本身正在运行,但我不明白为什么我每次都会错误查询数据库。,而不是实际添加数据库的价值。

将播放器注册到我制作的数据库的一个非常相似的脚本,工作得很好。我花了很多时间,我无法弄清楚为什么这个不起作用。

感谢帮助!谢谢!

0 个答案:

没有答案