Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C#列表中存储PHP数组_C#_Unity3d - Fatal编程技术网

在C#列表中存储PHP数组

在C#列表中存储PHP数组,c#,unity3d,C#,Unity3d,我正在编写一个原型,我在这里遇到了一个简单的问题。使用我的PHP脚本,我从数据库中获取值,这些值存储在数组中,但我无法……将这个数组传递到我的C#app中 问题是,我想将从PHP脚本中获得的内容存储到一个列表中 有没有办法做到这一点 我的C#代码: 那个php代码容易受到sql注入的攻击。为什么不使用JSON呢?可以用php序列化数组,用c#反序列化数组。。您还应该修复sqli。而且。。。C#完全可以直接查询MySql。为什么任何游戏制造商都想从游戏中发出bdd请求…@FistiPaul在安全和

我正在编写一个原型,我在这里遇到了一个简单的问题。使用我的PHP脚本,我从数据库中获取值,这些值存储在数组中,但我无法……将这个数组传递到我的C#app中

问题是,我想将从PHP脚本中获得的内容存储到一个列表中

有没有办法做到这一点

我的C#代码:


那个php代码容易受到sql注入的攻击。为什么不使用JSON呢?可以用php序列化数组,用c#反序列化数组。。您还应该修复sqli。而且。。。C#完全可以直接查询MySql。为什么任何游戏制造商都想从游戏中发出bdd请求…@FistiPaul在安全和有目的地引入关键漏洞和拥有深不可测的编码标准之间有一大步要走
public string pseudo;
public List<string> ListeMesCartes = new List<string>();
private void Start()
{
    pseudo = PlayerPrefs.GetString("JoueurPseudo");
    cartesJoueur();
}

public void cartesJoueur()
{
    WWWForm form = new WWWForm();
    form.AddField("Identifiant", pseudo);

    UnityWebRequest www = UnityWebRequest.Post("http://localhost/projet_environnement/MesCartes.php", form);
    www.SendWebRequest();
    if (www.isNetworkError || www.isHttpError)
    {
        Debug.Log(www.error);
        Debug.Log(www.downloadHandler.text);
    }
    else
    {
        // Read the returned value of the PHP script and add it to ListeMesCartes
    }
}
$SRVusername="root";
$SRVpassword="";
$SRVadress="localhost";
$SRVdatabase="projet_environnement";

$connexion=mysqli_connect($SRVadress,$SRVusername,$SRVpassword,$SRVdatabase);

if(mysqli_connect_errno())
{
    echo "1: Erreur de connexion";
    http_response_code(500);
    exit();
}
$Identifiant="Testeur";
$checkquery = "SELECT * FROM `joueurs_defis` WHERE `ID_JOUEUR`=(SELECT `ID_JOUEUR` FROM `joueurs` WHERE `PSEUDO`='".$Identifiant."');";
if($checkstate = mysqli_query($connexion,$checkquery))
{
    $MesCartes = [];
    while($MaCarte = mysqli_fetch_array($checkstate))
    {
        $MesCartes = $MaCarte;
    }
    var_dump($MesCartes);
} 
else 
{
    printf("4: Erreur lors de la requête %s\n", $checkquery);
    http_response_code(500);
    exit();
}
mysqli_close($connexion);