2016-11-15 67 views
0

所以我有什么是:PHP,MySQL的 - 如何正确传递变量的链接

$id = $_POST['id']; 
$loann = $_POST['loann']; 
$dater = $_POST['dater']; 
$apaid = $_POST['apaid']; 

...和:

$result = mysql_query("UPDATE _loan SET loana='$loann', dater = CONCAT_WS(',', dater, '$dater'), apaid = CONCAT_WS(',', apaid , '$apaid') WHERE id=$id"); 

    echo $id; 

一切正常,现在的问题显示了当我托盘传递的$ id入值:

echo ('<meta http-equiv="refresh" content="1;url=view_details.php?id=$id">'); 

我会得到在浏览器将是:

mysite.net/view_details.php?id=$id 

相反的:

mysite.net/view_details.php?id=133 

任何帮助是极大的赞赏。

+0

为什么不使用PHP header()函数进行重定向? http://php.net/manual/en/function.header.php – Maximus2012

+0

@ Maximus2012不幸的是,它没有奏效。 – Cluster

+1

该变量不会在单引号字符串中分析。 –

回答

5

您正在使用单引号字符串,该字符串不扩展变量。无论是使用双引号字符串:

"<meta http-equiv=\"refresh\" content=\"1;url=view_details.php?id=$id\">" 

或连接字符串:

'<meta http-equiv="refresh" content="1;url=view_details.php?id=' . $id . '">' 

边注:您的代码很容易受到SQL注入。您应该开始阅读herehere

+0

非常感谢你。 – Cluster