Jump to content
Sign in to follow this  
thimblemunch

HTTP Request not able to send land details?

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

Share this post


Link to post
Share on other sites

I don't get how the assigned strings land_name and land_description won't just send to php. I also don't get exactly how llEscapeURL will help with this.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
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?

Share this post


Link to post
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::

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

It's really easy to test, if you want some basic php script to try I can supply that.

I have tried different requests exactly like you explained with no luck.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...