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?

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.

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!