0

统一代码

Scorestr 没有传递给 php 变量,只有 $qfName 被保存在查询中。我是 php 和 unity 的新手。也许解释或简单的答案将不胜感激。:)

public GameObject gamectrl;

    public void CallRegister()
    {       
        StartCoroutine(Register());
    }
    IEnumerator Register()
    {     
        List<IMultipartFormSection> wwwForm = new List<IMultipartFormSection>();

        int var = gamectrl.GetComponent<GameController>().Score;
        string scorestr  = var.ToString();
        //UnityEngine.Debug.Log(abc);

        wwwForm.Add(new MultipartFormDataSection("score", scorestr));
        UnityWebRequest www = UnityWebRequest.Post("http://localhost/testphp/HighScore.php", wwwForm);
        yield return www.SendWebRequest();

    }

php代码

<?php   
include 'connectivity.php'; 

$_POST["score"] = 1;

$unityscore =  $_POST["score"] ;

$qfName = 'queryrunning';
$insertscorequery  = "INSERT INTO highscore (FirstName, HighScore ) VALUES ('$qfName' , '$unityscore' )";
mysqli

_query($con,$insertscorequery);
    ?>
4

0 回答 0