我对这个数据库/服务器的东西很新,所以请耐心等待。我无法弄清楚为什么这些变量不会从Unity发布到我的数据库。
这是我的PHP: - 我用非post变量替换了下面的$ _POST变量,它们工作得很好!所以我对我的PHP代码感到相对满意。
<?php
$servername = "localhost";
$DBusername = "id*****_zingzingzingbah";
$DBpassword = "*******";
$DBName = "id430563_fitness2017";
$firstname = $_POST["firstnamePOST"];
$lastname = $_POST["lastnamePOST"];
$username = $_POST["usernamePOST"];
$email = $_POST["emailPOST"];
$password = $_POST["passwordPOST"];
//$firstname = "aaaa";
//$lastname = "aaaa";
//$username = "aaaa";
//$email = "aaaa";
//$password = "aaaa";
// Make Connection
$conn = new mysqli($servername,$DBusername, $DBpassword, $DBName);
// Check Connection
if (!$conn) {
die ("Connection Failed. ". mysqli_connect_error());
} else { echo "Connection Success" ; // display some text or info on the screen }
$sql = "INSERT INTO user_info (firstname, lastname, username, email, password) VALUES('".$firstname."','".$lastname."','".$username."','".$email."','".$password."')";
$result = mysqli_query($conn, $sql);
if(!$result) {
echo "there was an error creating user specific table";
} else {
echo "Everything OK2";
}
&GT;
请参阅下面的Unity C#代码...
- 我有两个CreateUser函数,以便可以从Unity访问void one函数,否则我无法访问IEnumerator函数。
- insertUserInfo = new WWW (InsertUserInfoURL,form);
之后代码卡住了
- 收益率回报并没有回归。
public void CreateUser(string inputFirstname, string inputLastname, string inputUsername,string inputEmail,string inputPassword ){
StartCoroutine (CreateUser2 (inputFirstname,inputLastname,inputUsername,inputEmail,inputPassword));
}
private IEnumerator CreateUser2(string inputFirstname, string inputLastname, string inputUsername,string inputEmail,string inputPassword ){
WWWForm form = new WWWForm ();
inputFirstname = "bbb";
inputLastname = "bbb";
inputUsername = "bbb";
inputEmail = "bbb";
inputPassword = "bbb";
form.AddField ("firstnamePOST", inputFirstname);
form.AddField ("lastnamePOST", inputLastname);
form.AddField ("usernamePOST", inputUsername);
form.AddField ("emailPOST", inputEmail);
form.AddField ("passwordPOST", inputPassword);
print("getting here ok");
insertUserInfo = new WWW (InsertUserInfoURL,form);
yield return insertUserInfo;
print("why aren't you getting here");
我确定SQL代码是正确的(基于没有POST变量的测试)
我肯定会调用CreateUser函数(两者都是)
非常感谢有关排除这些内容的任何提示,因为我觉得我在黑暗中摸索
答案 0 :(得分:0)
好的,所以我终于明白了......
在WWW请求有时间解决之前,我正在Unity中更改我的场景。
可能是我代表的可怕编码!
感谢大家的评论