I am working with unity3d and c# and I am trying to save the fullname from unity application into the mysql db using php, I am using the following c# code, which works fine if I use no space between the first and last name e.g. MarkHolland. However, when there is a space as shown in the code i.e. ‘Mark Holland’ then it doesnt work, namely doesn’t store the data in mysql. Any idea any solution!?
public IEnumerator StoreData()
{
string fullname = "mark holland";
string post_url = _storeTaskDataURL + "fullname=" + WWW.EscapeURL(fullname);
WWW hs_post = new WWW(post_url);
yield return hs_post;
if (hs_post.error != null) {
print("There was an error in storing data " + hs_post.error);
}
}
Finally I solved the problem by adding WWW.EscapeURL to each parameter e.g. “fullname=” + WWW.EscapeURL(fullname), “schoolname=” + WWW.EscapeURL(schoolname) etc!!
Well, it’s hard to spot the error with that little information. First of all make sure your php script expect the data as GET variables since you do a GET-request. If you want to do a POST request you have to use WWWForm.
If you need it as GET parameters make sure you seperate your parameters from the URL with a “?”.
I am pretty sure the thing is in the Unity itself as when I copy/paste the url string generated in Unity into the browser URL it works fine even with spaces between first and last name, but it does not work from within unity!?