Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Key getting messed up in llHttpRequest. Advice?

Clayton Cinquetti
Registered User
Join date: 17 May 2005
Posts: 38
12-31-2006 11:47
I have a bug I'm trying to track down where the key value I put in an URL that I submit to a mySql database is altered when I send it from second life, but works fine when I enter it directly into my web browser. I thought it might be something that could be fixed by escaping the url, but I couldn't make that work. I'm hoping someone has some advice.

Here's how I create the URL I want my script to contact (with the name of the server changed):

// I create the string exactly as I would type it into the web browser
string urlForStoringStatus = "http://www.myserver.com/MySqlExample.php?command=store&key=objectStatus&value="
+myStatus+"&group=objectState&owner_key="+(string)llGetKey();

// I print out the string for debug purposes
llWhisper(0,urlForStoringStatus);

// I send it to the server
saveOfObjectStatusRequestid = llHTTPRequest(urlForStoringStatus,[HTTP_METHOD,"GET"],"";);

When I run this I see whispered in the chat area the exact string I intended to create:
http://www.myserver.com/MySqlExample.php?command=store&key=objectStatus&value=status0&group=objectState&owner_key=826cc6c6-0b8c-6521-d1b9-1dc845c394b8

However, when I look in the database the key has been stored as the value:
64a938c8-0c35-4de1-95e8-b55eca07b378

However, when I cut and paste the same string that was whispered into my web browser, I see the key properly stored as:
826cc6c6-0b8c-6521-d1b9-1dc845c394b8

What's the difference between these two method???
Peekay Semyorka
Registered User
Join date: 18 Nov 2006
Posts: 337
12-31-2006 15:05
There shouldn't be any difference.

If you whisper the url again exactly after the llHTTPRequest() call, what does it say?

-peekay
Stylez Gomez
Union Micro
Join date: 4 Jun 2004
Posts: 146
12-31-2006 15:30
That's odd. I can't really offer much help but I can tell you that the method I use (below) works fine.

LSL script puts a key into a url (in a money() event) using code similar to this:
CODE

...
string requesturl = url + "?action=payment&amount="+(string)amount+"&key="+(string)id+"&name="+llEscapeURL(llKey2Name(id))+"&parcel="+urlParcelName+"&pw="+passwordMD5;
paymentRequestID = llHTTPRequest(requesturl, [HTTP_METHOD,"GET"], "");
...


PHP stores it into a variable like this:
CODE

$userKey = $_GET["key"];


Then I run a MySQL statement similar to:
CODE

...
$query = "SELECT _field_ FROM _table_ WHERE avatarkey = '$userKey'";
$result = mysql_query($query, $connection);
...


Is the prim that is whispering the key the same prim that is sending the HTTP request?
_____________________
Clayton Cinquetti
Registered User
Join date: 17 May 2005
Posts: 38
12-31-2006 15:36
You know what. This was totally stupid. I should have paid more attention to the server side code I had copied. I didn't notice at first that when sent from in world the server side used the owner's key. When typed into a browser it used the passed key.

If anyone is interested in the complete results, I have them documented on my blog www.secondlifehowto.com.

What the application does is that whenever you touch an in world object, the state changes and that state is sent to a server where it's stored in a mysql database. From there anyone with a web browser can view the state of the object. Similarly, any one with a web browser can set the state of the server and the in world object will retrieve that state and display it on hovering text in world.