Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Sandstorm · Nov 06, 2013 at 06:49 AM · jsonmysqlphp

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:

 {"Graveyards":[{"SizeID":1,

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 :)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by flamy · Nov 06, 2013 at 07:06 AM

 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.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sandstorm · Nov 06, 2013 at 07:38 AM 1
Share

Goddamn flamy you just saved my day! Thank you :)

It works now, Now I get a "414 request-uri too long", but that's a webserver problem and I can handle that myself.

Thanks a lot :)

avatar image ben.aten · Apr 28, 2015 at 10:54 AM 0
Share

Hi how will you declare json string like "hi#bhyiuyiu&kljkmk J$$anonymous$$LJL$$anonymous$$Oo;ikmp;io &^7676nlkjl;iuoinui36#@&(&&%&%*&%&*n hjkghiugiu"

avatar image Bunny83 · Apr 28, 2015 at 11:28 AM 0
Share

@ben.aten: I'm sorry, but, what?? The "string" you posted there is not json and it looks like it hasn't any meaning since you just typed a random string. If you have a question, feel free to ask it as seperate question and don't post a comment to an answer on a completely different problem.

If you want to ask a question be more specific than this. Json is just a way to structure different data in a text format. It only supports some basic types (number, string, bool, array, object). A string value has to be escaped so it doesn't contain any of the special characters that make up the structure of the json file itself. It's explained in the RFC7159 section 7.

$$anonymous$$y SimpleJSON framework has these escape rules implemented.

avatar image ben.aten · Apr 28, 2015 at 11:54 AM 0
Share

@Bunny83 Thanks

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Load entire table from MySQL 1 Answer

Unity CrossDomain.xml Still Required? What is wrong? 0 Answers

How to get different variables from PHP page ? (example included)... 1 Answer

Yet an other MMO Question. 0 Answers

Unity PHP Database is going haywire 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges