Allright, I get that part.

the url is coming from unity

javascript part inside unity

the part in bold is doing the post data.

private var secretKey="mySecretKey";
function postScore(name, score) {
    //This connects to a server side php script that will add the name and
score to a MySQL DB.
    // Supply it with a string representing the players name and the players
score.
    var hash=Md5.Md5Sum(name +""+ score + ""+ secretKey);

    *var highscore_url = addScoreUrl + "name=" + WWW.EscapeURL(name) +
"&score=" + score + "&hash=" + hash;

    // Post the URL to the site and create a download object to get the
result.
    hs_post = WWW(highscore_url);*
    yield hs_post; // Wait until the download is done
    if(hs_post.error) {
        print("There was an error posting the high score: " +
hs_post.error);
    }
}


<?php

        $db = mysql_connect('mysql_host', 'mysql_user', 'mysql_password') or
die <http://www.perldoc.com/perl5.6/pod/func/die.html>('Could not
connect: '. mysql_error
());
        mysql_select_db('my_database') or
die<http://www.perldoc.com/perl5.6/pod/func/die.html>
('Could not select database');

        // Strings must be escaped to prevent SQL injection attack.
        $name = mysql_real_escape_string($_GET['name'], $db);
        $score = mysql_real_escape_string($_GET['score'], $db);
        $hash = $_GET['hash'];

        $secretKey="mySecretKey"; # Change this value to match the value
stored in the client javascript below

        $real_hash = md5($name . $score . $secretKey);
        if($real_hash == $hash) {
            // Send variables for the MySQL database class.
            $query = "insert into scores values (NULL, '$name', '$score');";

            $result = mysql_query($query) or
die<http://www.perldoc.com/perl5.6/pod/func/die.html>
('Query failed: ' . mysql_error());
        }
 ?>

This is the php side of things that I found online. Basically I am trying to
convert that to python code as you can see.

I wrote the getting part of the data and the rest is what I am working on
right now.

It would be nice,

if I could read values sent by unity(which is fine) and store them into
database rather than just displaying.

Thanks Karen.

Dhruv Adhia
http://thirdimension.com



On Thu, Oct 22, 2009 at 12:46 PM, Karen Tracey <kmtra...@gmail.com> wrote:

> On Thu, Oct 22, 2009 at 3:25 PM, Dhruv Adhia <druf...@gmail.com> wrote:
>
>> Yep and sorry I am bit new to this stuff, I mistook 69 for 200. This
>> explained it
>> http://cwiki.apache.org/GMOxSAMPLES/using-asynchronous-http-client.data/s200.log
>>
>> so for '?' then should my url pattern for add_Score look like this
>>   (r'^add_score/?', 'carbon_chaos.highscore.views.add_score'),
>>
>>
>>
> No, query strings don't play any part in the url matching.  You might want
> to add a $ to the end of your existing pattern, to indicate that the inbound
> URL path must end after the slash after add_score...as it is your requested
> URL is only matching because that $ is missing from your pattern, allowing
> any URL path that starts with add_score/ to get routed to your add_score
> view, even if there is more after the add_score/ element of the URL path.
>
> What you need to do to be able to access the query string values from the
> request.GET dictionary is change whatever is generating that URL to generate
> it properly, with the ? separating the URL path from the query string.  But
> near as I can tell you have not said anything about where that URL is coming
> from, so I don't know what to tell you tot fix.  You need the request coming
> in to the server to have the ? in its proper place, you do not need the ? in
> the pattern.
>
> Karen
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to