Jump to content

stecia1

Resident
  • Posts

    6
  • Joined

  • Last visited

Posts posted by stecia1

  1. Ok I managed to figure out the problem... I was trying to print the list in a single llSay..
    By using "string Q10 = llList2String(listQ, 10)"  my problem is solved....!!! So simple.. :smileyfrustrated:

    Thanks for the help!

  2. I have tried this ( listQ = listQ + [body] ), but when i print this listQ, it seems that it only saves the first 3 question that I put in that list. In fact, the third one is cut in the middle, so I figured that the list doesn't have enough space for all 30 questions I want to save...

    Is there any way to to save all 30 questions inside one list? Or the only alternative solution is to create 30 different lists foreach one?

    Thank you very much for the help...  I'm really confused here... :matte-motes-mad:

  3. I also have a question about lists and as long as I cannot start a new thread, I decided to post it here..

    I would very much appreciate your help and thank you in advance.. Excuse me for my ignorance... :)

    So, here is what I'm trying to do: I retrieve data from an SQL table through llhttprequest. I always read the first 30 rows of the table. Now I want to store this data inside a list (this data is "Questions"). I tried some of the following.. some return a syntax error:

    //"listQ" + Index = body;//listQ = llParseString2List(body,["\r\n","\n"],[]);//list newQ = [body];//listQ = listQ + newQ;//integer length = llGetListLength(listQ);//listQ = llListInsertList(listQ, newQ, length);//listQ[index] = newQ;//"listQ" + Index = newQ;//llOwnerSay( (string)newQ );   //listQ[index] = body;

    ... where "body" is the body of the request and "Index" is the counter for the next request.

    The problem is that the list listQ cannot store all 30 questions (in fact it only stores 2 Questions and the third stops in the middle). How can I treat my list as an array? For example, how can I do this...

    listQ[index] = body;

     ...or this, in order to have all the 30 records of the table inside listQ...?

    "listQ" + Index = body;
  4. Thank you very much for the reply! I tried this one and I think it will work now. But this creates an infinite loop... when the script runs, it returns to me all the Questions, Answers, Tips of the table, but then it returns empty records and never stops. Do you think I could make it stop when it finds empty record in the table? Or this should happen inside the php code?

     

    I'm sorry to post in this old thread, but I'm new to this forum and couldn't find where I could create new thread :P

  5. Hello everybody, I also have a problem with a script containing llhttprequest.

    I want the script to send requests to a web server and ask for the contents of a table. The table contains 3 columns: Question, Answer, Tip. I want to send the requests 30 times and take as a return 3 lists, each one containing the questions, the answers and the help. My lsl script is the following:

    key param1; // just to check if we're getting the result we've asked for; all scripts in the same object get the same replieskey param2;key param3;list question;list answer;list tip;default{    state_entry()    {        llSetText("Retrieve questions", <0.9, 0.4, 0.1>, 1.0);    }        touch_start(integer num)        {        integer i;        for ( i = 1; i <= 30; i++ )            {            param1 = llHTTPRequest("http://papavasa.webpages.auth.gr/opensim/send_data.php",                  [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],                 "paramQ=" + i);            param2 = llHTTPRequest("http://papavasa.webpages.auth.gr/opensim/send_data.php",                  [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],                 "paramA=" + i);            param3 = llHTTPRequest("http://papavasa.webpages.auth.gr/opensim/send_data.php",                  [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],                 "paramT=" + i);            }        }        http_response(key request_id, integer status, list metadata, string body)    {        if (request_id == param1)            question += llParseString2List(body,["\n"],[" "]);            llOwnerSay( (string)question );        if (request_id == param2)            answer += llParseString2List(body,["\n"],[" "]);            llOwnerSay( (string)answer );        if (request_id == param3)            tip += llParseString2List(body,["\n"],[" "]);            llOwnerSay( (string)tip );       //llOwnerSay(body);    }        }

     And my php code is this:

    <?// Only works with PHP compiled as an Apache module$headers = apache_request_headers();$objectName = $headers["X-SecondLife-Object-Name"];$objectKey     = $headers["X-SecondLife-Object-Key"];$ownerKey     = $headers["X-SecondLife-Owner-Key"];$ownerName = $headers["X-SecondLife-Owner-Name"];$region        = $headers["X-SecondLife-Region"];// and so on for getting all the other variables ...// get things from $_POST[]// Naturally enough, if this is empty, you won't get anything$parameter1 = $_POST["paramQ"];$parameter2 = $_POST["paramA"];$parameter3 = $_POST["paramT"];// Connect to MySQL$con = mysql_connect("localhost","stesia","stesia");if (!$con)  {  die('Could not connect: ' . mysql_error());  }// Select the databasemysql_select_db("stesia")   or die("Unable to select database: " . mysql_error());// Select only the row of the sent parametersif ( $parameter1 ){$result = mysql_query(" SELECT * FROM questions					   WHERE ID='" .$parameter1. "' ");$r = mysql_fetch_array($result);echo $r['Question'] . "\n";}else if ( $parameter2 ){$result = mysql_query(" SELECT * FROM questions					   WHERE ID='" .$parameter2. "' ");$r = mysql_fetch_array($result);echo $r['Answer'] . "\n";}else if ( $parameter3 ){$result = mysql_query(" SELECT * FROM questions					   WHERE ID='" .$parameter3. "' ");$r = mysql_fetch_array($result);echo $r['Help'] . "\n";}// close the connectionmysql_close($con);?>

     My problem is that the data returned is not in order (as in the table). I want to save the data in 3 different lists, one for questions, one for answers and one for tips. I don't know if i use correctly the http_request and response and the lists part..

    I would very much appreciate it if anyone could help me out. Thank you in advance! :matte-motes-bashful-cute:

×
×
  • Create New...