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 v3n0mou5 · Jan 07, 2015 at 03:34 PM · c#wwwphp

www php doesnt receive whole string

im making a inventory system that logs its items to a datbase server. i have most of it working but the problem im having is that i send a string of 200 chars to my php script, but when i echo it in my php script it only give me the first 24 characters of the string.

what i send:

{"name":"inventory", "array":[ {"ItemName":"White Shirt", "ItemID":"1", "ItemDesc":"A white T-shirt", "ItemPower":"0", "ItemSpeed":"0"}, {"ItemName":"Amulter of Prayers", "ItemID":"0", "ItemDesc":"An amulet enchanted by prayers", "ItemPower":"2", "ItemSpeed":"0"}, {"ItemName":"Brown Feather", "ItemID":"2", "ItemDesc":"A Brown Feather", "ItemPower":"0", "ItemSpeed":"0"}, {"ItemName":"Yellow Light", "ItemID":"3", "ItemDesc":"A Yellow Light", "ItemPower":"0", "ItemSpeed":"0"}, {"ItemName":"Large Health Potion", "ItemID":"4", "ItemDesc":"A Large Health Potion", "ItemPower":"0", "ItemSpeed":"0"}, {"ItemName":"Medium Power Potion", "ItemID":"5", "ItemDesc":"A medium Power Potion", "ItemPower":"0", "ItemSpeed":"0"}]}

what my php script echo's:

{\"name\":\"inventory\",

this is my php code:

 <?php
     
 
     $db = mysql_connect('localhost', 'name', 'pass')
     or die ('could not connect: ' . mysql_error());
     mysql_select_db('DB') or die('could not select database');
 
         // Strings must be escaped to prevent SQL injection attack. 
         $username = mysql_real_escape_string($_GET['username'], $db); 
         $inventory = mysql_real_escape_string($_GET['inventory'], $db);
         $hash = $_GET['key']; 
  
         $secretKey="mySecretKey2"; # Change this value to match the value stored in the client javascript below 
 
         $real_hash = md5($username . $inventory . $secretKey); 
 echo $inventory;
 
         //if($real_hash == $hash) { 
          $query = "INSERT into users values (0, '$username',NULL, 0,'$inventory');"; 
             $result = mysql_query($query) or die ('Query failed: ' .mysql_error());
                 
                     echo "SubmittedScore";
 
       //     } 
 
 ?>

and this is my c# function:

 IEnumerator handleSubmit()
     {
 
         gamemanager = GameObject.FindGameObjectWithTag ("gamemanager");
         string name = gamemanager.GetComponent<LoggedInUser>().loggedInUser;
         string key = Md5Sum(name + myInventory + secretKey);
     
         string submit_url = submitURL + "username=" + WWW.EscapeURL(name) + "&key=" + key + "&inventory=" + myInventory ;
         WWW submitReader = new WWW(submit_url);
         yield return submitReader;
         
         Debug.Log (submitReader.text);
         
 
 
     }


so my question is how do i get my php script to get the full string?

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
0

Answer by Victory Dan Greene · Jan 07, 2015 at 04:06 PM

At first blush, it looks like you may have forgotten to url-encode the "myInventory" component of the url you're hitting—so its $_GET value only includes the JSON up to the first word space (which isn't allowed in a url).

Comment
Add comment · Show 8 · 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 v3n0mou5 · Jan 07, 2015 at 04:55 PM 0
Share

ah right dude thanks.

do you maybe know what mysql_query i use to insert the string into the table of the user i send with the url post?

avatar image Victory Dan Greene · Jan 07, 2015 at 05:32 PM 0
Share

I'm not sure what your database schema is like, but isn't the line...

 $query = "INSERT into users values (0, '$username',NULL, 0,'$inventory');"; 

...isn't that what you want to run to add the inventory to the table?

avatar image v3n0mou5 · Jan 07, 2015 at 05:42 PM 0
Share

If i run that query it just creates a new entry with the same username but it doenst add the new inventory to the user is give with it.

It doesnt need to create a new user. It needs to add inventory to the current user wich i send to the php

avatar image Victory Dan Greene · Jan 07, 2015 at 05:47 PM 0
Share

If you're sure there is already a row for the current user, you probably want to obtain that row's id somehow and use an UPDATE statement like

 "UPDATE users SET inventory = '$inventory' WHERE id = '$id' ;"


avatar image v3n0mou5 · Jan 07, 2015 at 05:51 PM 0
Share

Ah right thanks man :D il give it a try and let u know

Show more comments

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

PHP POST through $_REQUEST with WEBBUILD 1 Answer

Is it possible to call a Javascript code on local server from Unity? (Google Chart API involved) 2 Answers

How do I know that php server is available? (C# script) 1 Answer

Unity C# I need my PHP page to Run (on the Server) Without me Getting or Sending Info 0 Answers

www.text + php + c# issue 2 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