Coroutines或Php脚本不适用于移动设备

Hi this is my first query using stack overflow so lets get to it. i am making an android game that uses database that is on a server of a site i am using phpmyadmin to manage mysql and here is how i retrieve data

public class Dataretrieve : MonoBehaviour {
WWW sitedata;
public string[] users;
public static string[] Usernames;
public static string[] Emails;
public static string[] Passwords;
public static string[] Icons;
// Use this for initialization
public  void Start(){
    StartCoroutine_Auto(StartGettingData);
}

public IEnumerator StartGettingData () {
    Debug.Log ("Starting to get values");
    sitedata = new WWW ("mysite/database.php");
    yield return sitedata;

    string sitedatatext = sitedata.text;
    users = sitedatatext.Split (';');

    Usernames=new string[users.Length-1];
    Emails=new string[users.Length-1];
    Passwords=new string[users.Length-1];
    Icons=new string[users.Length-1];

    for (int i=0; i<users.Length-1; i++) 
    {
        Usernames[i]=GetData(users[i],"Username:");
        Emails[i]=GetData(users[i],"Email:");
        Passwords[i]=GetData(users[i],"Password:");
        Icons[i]=GetData(users[i],"Icon:");
    }
    Debug.Log ("All Data Retrieved");
    StopCoroutine ("StartGettingData");
}
    string GetData(string data,string index)
{
    string value = data.Substring (data.IndexOf (index) + index.Length);
    if (value.Contains ("|"))
        value = value.Remove (value.IndexOf ("|"));
    return value;
}

public void values()
{
    Debug.Log ("Start getting values again");
    StartCoroutine_Auto(StartGettingData());
    StopCoroutine ("StartGettingData");
    Debug.Log ("Values Updated again");
}

}

The problem is it works fine on unity editor but when i run it on built it doesn't get users data

here's php code

$conn=new mysqli($servername,$username,$password,$dbName);
if(!$conn)
{
    die("Connection Failled".mysqli_connect_error() );
}

$sql="SELECT ID, Email, Password, Username, Icon FROM  Login_Variables";
$result = mysqli_query($conn ,$sql);


if(mysqli_num_rows($result) > 0)
    while(  $row =mysqli_fetch_assoc($result))
    {
        echo("ID:".$row['ID']."|Email:".$row['Email']."|Password:".$row['Password']."|Username:".$row['Username']."|Icon:".$row['Icon'].";");
    }

</div>
dptiq46022
dptiq46022 谢谢你们帮助了很多,但我发现这不是问题的根源
大约 4 年之前 回复
doucong4535
doucong4535 老大的WTF是“StartCoroutine_Auto”?嘿。立即删除-您只需要“StartCoroutine”。您还必须删除“值”中的其他“StopCoroutine”。一定要删除上面所见的“StopCoroutine”的所有用法。请注意,“值”必须称为“值”。你必须在Unity3D中为类名,变量名使用正确的大小写模式。
大约 4 年之前 回复
dongxian3852
dongxian3852 嘿艾哈迈德,你的代码有严重的问题。你不应该在同一个协程中调用“StopCoroutine”。(如果您碰巧想要离开,退出,那么只需“收益休息”。)
大约 4 年之前 回复
dongyong6428
dongyong6428 通过互联网,但使用本地主机
大约 4 年之前 回复
dongping1012
dongping1012 php文件托管在哪里?本地还是互联网?
大约 4 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐