- Home /
WWW with php file cannot sent more than 6 values ?
Hello, I'm inserting new entries in a tables with a php script, and i'm passing values to this script with unity. Everything works fine, until I'm sending more than 6 values at same time ? here's my code :
IEnumerator InsertRequest(){
insertLink += "?lat="+baseController.lat
+"&lng="+baseController.lng
+"&etat="+baseController.etat
+"&nom="+baseController.nom
+"&espece="+baseController.espece
+"&taille="+baseController.taille
+"&race="+baseController.race
+"&poils="+baseController.poils
;
print (insertLink);
www = new WWW(insertLink);
//Load the data and yield (wait) till it's ready before we continue executing the rest of this method.
yield return www;
if (www.error == null)
{
//Sucessfully loaded the JSON string
Debug.Log("ok");
}
else
{
Debug.Log("ERROR: " + www.error);
}
}
it debugs "ok", but don't do the entry in the database? There's more , if i manually copy/paste the link outputed by the (print(insertlink)) in a browser, the request is ok and the entry in the database is done. Weirder : if in the unity script i only pass 6 parameters(in this example i don't pass "race" & "poils" params, it's working and the entry in the database is done !
How can it be possible?
Does baseController.taille contain any special characters? If it includes a space or quote it might be the rest of the URL isn't well formed. You might need to URLEncode the parameters.
When you paste it into a browser, the browser fixes it and sends the whole thing
In fact, I said 6 params because I made multiple tests, if i pass vars until "espece" var, it's ok. if i go until "taille" , it doesnt work, BUT if i don't pass the "espece" var but i pass "taille" ins$$anonymous$$d : it works too ..
So I guess my problem is server sided ? Can you show me the part of your php request file that receive the vars?
Answer by Eidern · Feb 17, 2016 at 11:20 PM
Someone found the answer on another post , So I give it for those who can have the same problem.
The URL got a character limit, so if you pass long var names, with long values, at a point you'll get this error too.
You'll have to switch to a WWWForm method and use POST, instead of GET in your php file to retrieve the values.
WWWForm form = new WWWForm();
form.AddField( "lat", baseController.lat.ToString());
form.AddField( "lng", baseController.lng.ToString() );
form.AddField( "etat", baseController.etat );
//and so on...
// Upload
WWW w = new WWW(insertLink, form);
yield return w;
if (!string.IsNullOrEmpty(w.error)) {
print(w.error);
}
else {
print (w.text);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612064534im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Making a bubble level (not a game but work tool) 1 Answer
WebClient on Android 0 Answers
An OS design issue: File types associated with their appropriate programs 1 Answer