Jump to content

HTTP Request not able to send land details?


thimblemunch
 Share

You are about to reply to a thread that has been inactive for 2620 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello I'm trying to send land details with llHTTPRequest and save them in a database on start.

I've done this a million times before and it worked perfectly fine if I exchange the land variable with just regular strings so I know it's something in my LSL and not PHP/MySQL.

string owner_name;
string clicked_name;

string parcel_name;
string parcel_description;
string parcel_location;

key owner_key;
key clicked_key;
key parcel_key;

// HTTTP REQUEST //
key treasure_add_key;

list treasure_add_list = [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"];

string treasure_add_url = "";

default
{
    state_entry()
    {
        owner_key = llGetOwner(); // Assign the owner key.
        owner_name = llKey2Name(owner_key); // Assign the owner name.
        
        list landDetails = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_ID, PARCEL_DETAILS_NAME, PARCEL_DETAILS_DESC]);
        parcel_key = llList2String(landDetails, 0);
        parcel_name = llList2String(landDetails, 1);
        parcel_description = llList2String(landDetails, 2);
        llOwnerSay((string)parcel_key);
        llOwnerSay(land_name);
        llOwnerSay(land_description);
        
        treasure_add_key = llHTTPRequest(treasure_add_url, treasure_add_list, "&owner_key=" + (string)owner_key + "&owner_name=" + owner_name + "&parcel_key=" + (string)parcel_key + "&parcel_name=" + parcel_name + "&parcel_description=" + parcel_description);
    }

    http_response(key request_id, integer status, list metadata, string body)
    {
        if(request_id == treasure_add_key)
        {
            llOwnerSay(body);
        }
    }

    touch_start(integer total_number)
    {
        treasure_add_key = llHTTPRequest(treasure_add_url, treasure_add_list, "&owner_key=" + (string)owner_key + "&owner_name=" + owner_name + "&parcel_key=" + (string)parcel_key + "&parcel_name=" + parcel_name + "&parcel_description=" + parcel_description);
    }
}

The problem is with parcel name and description, I can add the other ones fine but when those two come up it breaks the query. I have managed to track it down to my LSL script by exchanging them to regular strings, but the second I try with the real land information it doesn't work. I've tried everything in my power to fix this from rewriting it over and over to even reinstalling phpmyadmin.

Please someone help me as this is pretty much my last attempt.

If you need php script it's a simple INSERT into query, not hard!

This is a working version of the same script. Notice where I assign the variables to regular strings instead.

string owner_name;
string clicked_name;

string land_name;
string land_description;
string land_location;
string parcel_name;
string parcel_description;
string parcel_location;

key owner_key;
key clicked_key;
key parcel_key;

// HTTTP REQUEST //
key treasure_add_key;

list treasure_add_list = [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"];

string treasure_add_url = "";

default
{
    state_entry()
    {
        owner_key = llGetOwner(); // Assign the owner key.
        owner_name = llKey2Name(owner_key); // Assign the owner name.
        
        list landDetails = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_ID, PARCEL_DETAILS_NAME, PARCEL_DETAILS_DESC]);
        parcel_key = llList2String(landDetails, 0);
        // parcel_name = llList2String(landDetails, 1);
        // parcel_description = llList2String(landDetails, 2);
        parcel_name = "Parcel name";
        parcel_description = "Parcel Description";
        llOwnerSay((string)parcel_key);
        llOwnerSay(land_name);
        llOwnerSay(land_description);
        
        treasure_add_key = llHTTPRequest(treasure_add_url, treasure_add_list, "&owner_key=" + (string)owner_key + "&owner_name=" + owner_name + "&parcel_key=" + (string)parcel_key + "&parcel_name=" + parcel_name + "&parcel_description=" + parcel_description);
    }

    http_response(key request_id, integer status, list metadata, string body)
    {
        if(request_id == treasure_add_key)
        {
            llOwnerSay(body);
        }
    }

    touch_start(integer total_number)
    {
        treasure_add_key = llHTTPRequest(treasure_add_url, treasure_add_list, "&owner_key=" + (string)owner_key + "&owner_name=" + owner_name + "&parcel_key=" + (string)parcel_key + "&parcel_name=" + parcel_name + "&parcel_description=" + parcel_description);
    }
}

Using llOwnerSay I also was able to tell that the land details were grabbed correctly.

If this a new bug by chance?

Thanks

Link to comment
Share on other sites

Okay I'm still kind of confused about llEscapeURL. Say I grab the land name and save it into a string, the spaces in the land name will break the string? I've never really used llEscapeURL or understood fully what it does. I tried changing my land name to no spaces and it didn't fix it.

Link to comment
Share on other sites

Without knowing what your data look like, all Qie and I can do is guess.  His point, though, is that if you use llEscapeURL on each of your strings, it will convert the blanks to %20 and will make similar changes in other characters that would otherwise break the strings as they are used as arguments in your HTTP calls. When we are sending a region name, for example, we'd send it as llEscapeURL(llGetRegionName()) rather than just llGetRegionName() .  That way, Da Boom gets sent as Da%20Boom.  What we're trying to avoid by doing this is explained in the caveats for the wiki entry for llHTTPRequest:

If there is a space in url, the http_response status code will be 499.

Link to comment
Share on other sites

Okay that mostly makes sense, but it doesn't explain when I change the strings to regular strings for example "Land Name" it will work fine even with the space, it adds it to the database and everything properly.

I think I'm just not catching on here, would I llEscapeURL the http url or the variables I am passing?

Link to comment
Share on other sites

Not the entire URL, but parts of it.  Again, as the wiki entry for llEscapeURL explains:

The function is not appropriate for escaping a url all at once, because the ":" after the protocol, and all of the "/" characters delimiting the various parts, will be escaped. Instead, build the url in parts; escaping parts of the path and query string arguments as needed.

You're really after the blanks in the URL.  You don't want to escape the ":" or the "?", for example.

Link to comment
Share on other sites

It should be.  Hmmmm..   Time to grasp at straws.

A couple of small things might help.  First, you defined parcel_key as a global key variable, yet you loaded it as a string:

        list landDetails = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_ID, PARCEL_DETAILS_NAME, PARCEL_DETAILS_DESC]);        parcel_key = llList2String(landDetails, 0);

That shouldn't make a difference, but you never know.  Second, the parcel_name and parcel_description shouldn't have any blanks in them, but you might try being sure that there aren't any leading or trailing blanks that you wouldn't see with your llOwnerSay diagnostic.  Use llStringTrim to lop them off, if they are there.

Link to comment
Share on other sites

After lots of messing around I have found that any variable that is grabbed from llGetParcelDetails and sent into a database just doesn't seem to work at all. I've tried so many things and I'm dead out of ideas. I have done this around 4-6 months ago this exact same way but now it doesn't work for some reason.

I've tried it with a blank script with just those variables getting sent and nothing. Is anyone able to replicate this by chance?

Link to comment
Share on other sites


thimblemunch wrote:

Now I'm really confused cause the url doesn't have any spaces in it. It works perfect for the land_key variable I assigned the same way using llGetParcelDetails but when I try land_name it stops there. So the url should be good at least to go?

It's not only spaces. Imagine the confusion if a name or description contains a "&" or "?".

If you're already URL-escaping those strings, though, I'm out of ideas. Does this fail for all parcels regardless of name and description? Is there some way you can see a server log file, separate from the database stuff, to detect what (if anything) is getting across the wire?

Link to comment
Share on other sites

it's hard to say without being able to test, but have you tried changing your request at all?

mebbe try different versions of something like...

 

list treasure_add_list =

                         [ HTTP_METHOD, "GET",
                           HTTP_MIMETYPE, "text/plain;charset=utf-8",
                           HTTP_BODY_MAXLENGTH,16384];

 

::shrugs::

 

Link to comment
Share on other sites

Yes I've llEscapedURL all the strings with no luck. I don't really use my server log for this kind of thing cause I don't know if it would even output important information or able to even catch it cause the issue is in LSL.

Say I change land_name to "Test Name", that will work fine and send it to the database. The second I try to change them with the strings from the land then it breaks it.

This should work but it doesn't for some reason.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2620 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...