- Home /
Store data in MySQL DB
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);
}
}
Thanks in advance
Answer by UnityDeveloper · Dec 01, 2011 at 03:23 PM
Finally I solved the problem by adding WWW.EscapeURL to each parameter e.g. "fullname=" + WWW.EscapeURL(fullname), "schoolname=" + WWW.EscapeURL(schoolname) etc!!
Answer by Bunny83 · Nov 30, 2011 at 03:27 AM
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 "?".
Answer by UnityDeveloper · Nov 30, 2011 at 11:59 AM
,Thanks but none of the proposed solutions fixed the issue.
I am already using "?" in the url
Also I am using the GET not POST in the php as follows
$userId = $_GET['userId'];
$query = "insert into profileTable values (NULL, '$fullname');";
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!?
Any more suggestions / help
Thanks
Your answer

Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
MySQL Funktionen Hilfe 1 Answer
Multiple Cars not working 1 Answer
A node in a childnode? 1 Answer