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 JDB-Artist · Aug 16, 2012 at 04:45 PM · wwwyieldurl

WWW execution (working in browser)

Hi again,

I am facing a very weird situation right now. I have a script which basically collects some data and tries to upload it to my mysql database. The process is verified by a md5 hash comparison.

So this is what happens: When I call my script via runtime it get's executed up to a very certain point and stops there for some reason I don't know yet (and I really hope that you can help me out here^^).

So this is the scenario:

Client side

 var uploadScore = UploadScoreUrl + "name=" + WWW.EscapeURL(username) + "&score=" + &hash=" + hash;

Server Side

 $real_hash = md5($name . $score . $secretKey);
 if($real_hash == $hash) {$query = "insert into game_data values (NULL, '$name', '$score');";
 ´$result = mysql_query($query) or die('Query failed: ' . mysql_error());


So the weird thing is that if I print out the upload url that is generated on the client side (i.e. uploadScore) and execute it via the address bar in firefox the entry get's added to the database successfully. However this is not the case when I play the game. So by this I know that the Url is correct and indeed working! So what's next is to find the reason why the url is not submitted or executed during runtime.

I am using this code on client-side to submit the url:

 score_post = WWW(uploadScore);
     yield score_post; // Wait until the download is done
     if(score_post.error) {
         print("There was an error posting the score: " + score_post.error);
 
     }
     print (score_post.text);

Now this is what the last print tells me after the script has been called:

Connect to databse - Success! Get Score Information - Success! Hash is Fine! 208b74bc907059b208865033cb5c824d

However if I print the url out and execute it in the browser then the hash is different but the entry get's submitted successfully. (Hash in browser: 19d837242ac8eb9ac7daea90f7a53173)

So yes I believe that the script stops execution right before the hash comparison as the client says: Connect to databse - Success! Get Score Information - Success! Hash is Fine! 208b74bc907059b208865033cb5c824d

and the server says:

Connect to databse - Success! Get Score Information - Success! Hash is Fine! 19d837242ac8eb9ac7daea90f7a53173 19d837242ac8eb9ac7daea90f7a53173 Data Submitted successfull!


For your reference here's the code that's running on the server and obviously called by the client:

 // This is the code that follows after the Hash is Fine! statement which is also to be found in the output log and therfore a proof that the script on the server is executed up to this point.
 
 $real_hash = md5($name . $score  . $secretKey);
         echo " Hash is Fine!  ";
         echo $real_hash; //Generated by Server
         echo "   ";  // Divider space for better representation
         echo $hash; // Generated by Client
         if($real_hash == $hash) {
             // Send variables for the MySQL database class.
             $query = "insert into game_data values (NULL, '$name', '$score');";
             echo "Preparing Data.";
             $result = mysql_query($query) or die('Query failed: ' . mysql_error());
             echo " Data Submitted successfull!";
         }


Again, the question is, why does the client generated url work in a browser like firefox, opera and chrome but not ingame?

Comment
Add comment · Show 2
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 irfanbashasheik · Aug 16, 2012 at 06:57 PM 0
Share

I am also facing the same problem. I tried restarting the server. It worked once, but now again the same problem. Please post if you find an answer.

avatar image Bunny83 · Aug 16, 2012 at 07:28 PM 0
Share

It seems the hash that is sent by the client contains illegal characters. The php script will just die silently in such a case. I'm a php novice. I tried some things in php and this was the first thing i absolutely hate about it. It makes debugging nearly impossible. Usually i just print / Debug.Log / whatever when i'm new to a system. I can do some tests how the system behaves. But php just quits execution when the data you echo / print contains illegal characters. I'm not sure what those characters are, but it could be a " or '.

2 Replies

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

Answer by JDB-Artist · Aug 16, 2012 at 08:16 PM

Thanks for your comments, I did not find the wrong character within the client script nor within the server script but as this script doesn't transfer valuable data I decided to drop the hash check on server side and now it stores the info correctly within the database.

I will post here if I find the char that mixes things up. THX for your help!

Comment
Add comment · 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
0

Answer by irfanbashasheik · Aug 16, 2012 at 09:11 PM

Hi,

I am also trying to fix similar problem. So far what i have noticed is the url string which i am building is missing some format.

Comment
Add comment · Show 2 · 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 irfanbashasheik · Aug 16, 2012 at 08:23 PM 0
Share

I got it fixed. Just replace the spaces that you have in your url with %20.

avatar image Bunny83 · Aug 17, 2012 at 11:38 AM 0
Share

@irfanbashasheik: That's what WWW.EscapeURL is good for.

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

10 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

Related Questions

Max String Length in WWW url's? 1 Answer

location of file downloaded with WWW 1 Answer

How to assign texture from url 1 Answer

WWW isDone when lost internet connection, it return true and not wait for internet connection (Andriod) 1 Answer

NullReferenceException in nested Coroutine 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