Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.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 for MySQL(Unity)_C#_Php_Mysql_Sqlite_Unity3d - Fatal编程技术网

将变量从C#发送到php for MySQL(Unity)

将变量从C#发送到php for MySQL(Unity),c#,php,mysql,sqlite,unity3d,C#,Php,Mysql,Sqlite,Unity3d,我是MySQL系统的新手。我必须存储在数据库中: 用户名; 分数 资源 对于发送用户名、分数和资源,我没有任何问题,但当我尝试从数据库获取资源时,我出现以下错误: </style> </head> <body> <h1>Bad request!</h1> <p> Your browser (or proxy) sent a request that this server could not understand.

我是MySQL系统的新手。我必须存储在数据库中:

用户名; 分数 资源

对于发送用户名、分数和资源,我没有任何问题,但当我尝试从数据库获取资源时,我出现以下错误:

</style>
</head>

<body>
<h1>Bad request!</h1>
<p>


Your browser (or proxy) sent a request that
this server could not understand.

</p>
<p>
If you think this is a server error, please contact
the <a href="mailto:postmaster@localhost">webmaster</a>.

</p>

<h2>Error 400</h2>
<address>
<a href="/">localhost</a><br />
<span>Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/7.1.1</span>
</address>
</body>
</html>


UnityEngine.Debug:Log(Object)
<SetPlayerName>c__Iterator1:MoveNext() (at       Assets/Scripts/DataBase/MySQL/DBLoader.cs:67)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
如果我改变这一点:

$sql = "SELECT Coins FROM score WHERE Name = '" . $coinsname . "'";
为此:

$sql = "SELECT Coins FROM score WHERE Name = 'PlayerName'";
在布劳尔,我看到了分数


提前谢谢

您的php将永远找不到
$\u请求['coinsnameGet']
,因为您创建的URL如下所示:

string setName = postCoinsData + "coinsnameGet = " + WWW.EscapeURL(dbLocal.GetName());
这看起来像:

=PlayerName

但是看起来应该像

不完全确定这是否是导致问题的原因,或者这是否是复制粘贴错误,但如果是,则应将代码更改为:

string setName = postCoinsData + "?coinsnameGet=" + WWW.EscapeURL(dbLocal.GetName());
您对查询非常开放,应该真正使用而不是连接查询。特别是因为你根本没有逃避用户的输入!这不仅仅是一个安全问题,但是如果输入包含例如
-字符或反斜杠,那么您的查询将失败。
string setName = postCoinsData + "coinsnameGet = " + WWW.EscapeURL(dbLocal.GetName());
string setName = postCoinsData + "?coinsnameGet=" + WWW.EscapeURL(dbLocal.GetName());