Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Why isn't this working? (*sighs*)

Ryker Beck
Photographer & Designer
Join date: 23 Feb 2007
Posts: 57
05-29-2009 09:44
I'm a scripting amateur really, but I've been working on this for days now, and refuse to just give up because this one decided it didn't want to work. -.-

The script below, ideally, is supposed to (on_rez) communicate with an offline database (via a URL) and insert the card owner into the database as a new record.

I've tested the PHP page itself using the variables that this script is supposed to pass, and it actually works fine (I've replaced the URL and the password variables in the script below, but they are correct in my script in-world). But this script, when I put it into an object, does... nothing. It spits out the two llSays (registering and the cardholder uuid) and that's it. I get nothing from the URL or anything. No error messages, no SQL syntax problems, nothing at all from the URL.

Even if I replace this line:

CODE
llHTTPRequest(url+"?uuid=
"+llEscapeURL(cardHolder)+
"&points="+llEscapeURL(points)+
"&action="+llEscapeURL(action)+
"&password="+llEscapeURL(secret),
[HTTP_METHOD, "GET", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],"");


with this one (with legitimate values of course - line breaks are added to make this easier to read on the forums):

CODE
llHTTPRequest("http://www.example.com/example/example.php?password=stuff
&uuid=stuff
&action=stuff",
[HTTP_METHOD, "GET", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],"");


I still get absolutely nothing! :( It's really frustrating, and I honestly now have no idea what I could be doing wrong. The script is no where near finished, there's several things I still need to do with it, but my first hurdle (getting the script to talk to the database) is the one I can't seem to tackle now.

Any ideas? Any help appreciated.

Thanks!

- R

CODE
string points = "0"; //default # of points to add to card

// key holders and variables
key cardHolder;
key registerCard;
string action;

// database stuffs
string secret = "example"; //password for server requests
string url = "http://www.example.com/example/example.php";

default
{
state_entry()
{
llSay(0,"Registering your card...");
string action = "register";
key cardHolder = llGetOwnerKey(llGetOwner());
registerCard = llHTTPRequest(url+
"?uuid="+llEscapeURL(cardHolder)+
"&points="+llEscapeURL(points)+
"&action="+llEscapeURL(action)+
"&password="+llEscapeURL(secret),
[HTTP_METHOD, "GET", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],"");
llSay(0,cardHolder);
}
// reset script onRez
on_rez(integer start_param){
llResetScript();
}
// http response information handlers
http_response(key id, integer status, list metadata, string body)
{
if(id == registerCard){
// if registration is successful
if(body == "registered"){
llSay(0,"Successful.");
llRemoveInventory(llGetScriptName());
}
// already own a card
if(body == "existing"){
llSay(0,"Existing.");
}
if(status != 200){
body = "ERROR: Cannot connect to server.";
}
if(status = 499){
body = "ERROR: Request timeout.";
}
}
}
}
Caer Balogh
Registered User
Join date: 27 Jul 2007
Posts: 1
05-29-2009 10:02
Try moving the request body to the last parameter of llHTTPRequest, that is, change the llHTTPRequest to:

registerCard = llHTTPRequest(
url,
[HTTP_METHOD, "GET", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],
"uuid="+llEscapeURL(cardHolder)+"&points="+llEscapeURL(points)+"&action="+llEscapeURL(action)+"&password="+llEscapeURL(secret)
);

Note that you omit the "?" before "uuid..." since you get that for free when you put that stuff in the body argument.

If that doesn't work, you might then try omitting the llEscapeURL calls when passing the body in the 3rd arg, since llHTTPRequest may already do that to the body (I'm not certain).

Hope this helps.
Ryker Beck
Photographer & Designer
Join date: 23 Feb 2007
Posts: 57
05-29-2009 10:06
nope, still nothing. :( *cries* lmao
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
05-29-2009 10:57
You could check the logfiles of your server to see if the viewer connects to it.
If it doesn't, maybe you have some firewall problem?
Ryker Beck
Photographer & Designer
Join date: 23 Feb 2007
Posts: 57
05-29-2009 11:04
It's working now. A typical PEBKAC error. -.- lmao
Thanks, everyone!
Papalopulus Kobolowski
working mind
Join date: 11 Aug 2006
Posts: 326
05-29-2009 11:57
try "POST"
registerCard= llHTTPRequest( url, [HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded"],"uuid="+llEscapeURL(cardHolder)+"&points="+llEscapeURL(points)+"&action="+llEscapeURL(action)+"&password="+llEscapeURL(secret);
_____________________


RAW terrain files - terraform your SIM!!
http://www.wishland.info/
PD:the wiki its your friend ;)
http://wiki.secondlife.com/wiki/LSL_Portal
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
05-29-2009 12:20
Ryker, please do us all a favor: next time, please put a clue to the subject in your post. Most of the posts in this forum match your title. You want the attention of people who use HTTP requests, so mention it! A moment of your time saves a moment of time for all the people who open your thread just to find it's in an area where they have no interest or experience.

Also, a lot of very helpful but also busy folks will simply skip threads with no clue as to the subject.

When you take a moment to choose a good thread title, you're being more polite and often getting better help as well.

Thanks!