0

我正在运行 SQL 查询来插入数据并向用户发送通知。

$query = "INSERT QUERY";    
$result = mysql_query($query);
$last_entry = mysql_insert_id();

通知代码。

$params = array("access_token"=>"MY_ACCESS_TOKEN","template"=>"Sample template","href"=>"index.php?id='$last_entry'");
$response = $facebook->api("/" . $reciever_id . "/notifications","POST",$params );

在索引页面中,我正在捕获 id 并使用以下代码对其进行回显-

if(isset($_GET['id']))
{
    $message_id = $_GET['id'];
    echo $message_id;
}

尽管一切正常并且数据存储和通知功能都可以正常工作,但是在索引页面中,如果我在表中的 id 为 35,我将 id 设为 \'35\'。为什么将 \' 添加到 id 的开头和结尾?

如果\'是不可避免的,是否有任何php函数可以帮助我消除它们?

4

1 回答 1

1

single quotes从中删除$last_entry,例如,

$params = array("access_token"=>"MY_ACCESS_TOKEN",
                "template"=>"Sample template",
                "href"=>"index.php?id=$last_entry");
$response = $facebook->api("/" . $reciever_id . "/notifications","POST",$params );

还要检查一下,你进去了expected id$last_query

您可以检查numeric您的情况,例如,

if(isset($_GET['id']) and is_numeric($_GET['id']))
{
    $message_id = $_GET['id'];
    echo $message_id;
}
于 2013-07-29T05:13:39.030 回答