I have the following problem. I'm updating my mysql database using LSL. There is a corresponding table in the database and there is update.php with appropriate settings (have tested it with html form and php). Problem is that the record is added but with no values in the appropriate fields.
string time;
string address;
string message;
integer num_left;
integer listen_handle;
default
{
state_entry()
{
llSay(0,"Touch to insert messages into DB");
}
touch_start(integer total_number)
{
key owner = llGetOwner();
string name = llKey2Name(owner);
integer strlength = llStringLength(message);
string url = "http://antima.freehostia.com/update.php?";
float timing = llGetTime(); //Instead getting, and then resetting the time, we could use llGetAndReset() to accomplish the same thing.
llResetTime();
//time = (string)timing;
time = "12:23";
address = "here";
message = "This is a test of url";
num_left = 12;
url += time;
url += address;
url += message;
url += "12";
//url += (string)num_left;
llHTTPRequest(url, [HTTP_METHOD, "POST"], "");
}
}
Update
I have changed the code to:
time = "12:23";
address = "here";
message = "This is a test of url";
num_left = 12;
url += "id" + id;
url += "&" + time;
url += "&" + address;
url += "&" + message;
url += "&" + "12";
but I have a problem with getting the data using POST. On the PHP side I use this to retrieve values:
$data = $_POST;
$var = explode("&", $data);
$time = $var[1];
$address=$var[2];
$message=$var[3];
$num_left=$var[4];
however something is still wrong (I think this time with PHP side) and another empty record is added. I have tested the response provided by LSL by simply typing:
$data = "http://antima.freehostia.com/update.php?&12:23&here&This is a test of url&12";
and it worked.
How can I get the whole string from $_POST without specifying names of the fields and store it in the $data variable? Maybe it is something easy, but I could not find anything. Most of PHP uses some form and form fields.