Unity Php post JSON string problem (incomplete string)

Hi, I haven’t been able to find a solution for this particular problem, so here goes:

My problem is that when I use unity to post data to a database through a PHP page, the complete string isn’t uploaded. This is best illustrated with an example:

WWW playerUpdateRequest = new WWW("http://******/testJSON.php?test=" + jsonString);

Where my jsonString item, is formatted correctly, and starts something like this:

{"Graveyards":[{"SizeID":1, "PlotCount":9, "GraveyardID":1, "Plots":[{.....

Now, I tried storing the posted string in a database, and the result is that I only get the first part of the string:


That’s the entire content of the table item!

If I do it manually by going to that page and running

testJSON.php?test={"Graveyards":[{"SizeID":1, "PlotCount":9, "GraveyardID":1, "Plots":[{.....

Then it works fine and my database record shows the complete string (with any commas and quotes preserved).

This means that the php argument works fine, and that the database string insertion works fine as well (since I can get a complete hole through by doing it manually). For completeness sake in case quotes caused problems, I did try a string replacement, and replaced all quotes with ^, but this changes nothing. The database still holds only a fraction of the json string.

This leaves me isolating the problem to how unity posts the WWW request. Therefore I have put this post here, and I hope someone can help me solve this mystery :slight_smile:

WWW playerUpdateRequest = new WWW(“http://******/testJSON.php?test=” + jsonString);

change this to

WWW playerUpdateRequest = new WWW("http://******/testJSON.php?test=" + WWW.EscapeURL(jsonString));

check more details on this page. The problem seems to be with the spaces in the string.

If this doesnt solve the issue, try printing the value of jsonString and check if it is complete.