Php 使用LSL更新MySQL数据库时出现问题

Php 使用LSL更新MySQL数据库时出现问题,php,mysql,linden-scripting-language,Php,Mysql,Linden Scripting Language,我有以下问题。我正在使用LSL更新我的mysql数据库。数据库中有一个对应的表,并且有一个带有适当设置的update.php(已经用html表单和php对其进行了测试)。问题是添加了记录,但相应字段中没有值 string time; string address; string message; integer num_left; integer listen_handle; default { state_entry() { llSay(0,"T

我有以下问题。我正在使用LSL更新我的mysql数据库。数据库中有一个对应的表,并且有一个带有适当设置的update.php(已经用html表单和php对其进行了测试)。问题是添加了记录,但相应字段中没有值

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"], "");
    }
}
更新 我已将代码更改为:

    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";
但是我在使用POST获取数据时遇到了一个问题。在PHP端,我使用它来检索值:

$data = $_POST;
$var = explode("&", $data);
$time = $var[1];
$address=$var[2];
$message=$var[3];
$num_left=$var[4];
但是仍然有一些问题(我认为这一次是PHP端),添加了另一个空记录。我通过简单键入以下内容测试了LSL提供的响应:

$data = "http://antima.freehostia.com/update.php?&12:23&here&This is a test of url&12";
它成功了


如何在不指定字段名称的情况下从$\u POST获取整个字符串并将其存储在$data变量中?也许这很简单,但我什么也找不到。大多数PHP都使用一些表单和表单字段。

在发送请求之前将URL回显给您自己,希望您能看到问题所在。您的URL是通过将字符串值连接在一起来组装的,而不是将其设置为将这些值分配给请求变量

您想要做的可能是:

    time = "12:23";
    address = "here";
    message = "This is a test of url";
    num_left = 12;
    url += "time=" + time;
    url += "&address=" + address;
    url += "&message=" + message;
    url += "&num_left=" + num_left;

使用POST时,可以将数据作为字符串放入第三个参数中,如下所示:

llHTTPRequest("http://antima.freehostia.com/update.php", [HTTP_METHOD, "POST"],
   "12:23&here&This is a test of url&12");
将数据与URL放在一起的一个问题是,首先需要使用llEscapeURL()对其进行编码,但不需要使用POST并将数据放在第三个参数中

llHTTPRequest("http://antima.freehostia.com/update.php", [HTTP_METHOD, "POST"],
   "12:23&here&This is a test of url&12");