我希望在下一页的网址中获取ID。但是有很多%
和带有id的数字。例如:我的id应该在url之后13。但它变成了
http://localhost/daudkandi/photo_upload.php?id=%27%20.%2013%20.%20%27
如何删除%和额外数字?
这是我的总代码
<?php @session_start(); ?>
<?php include "db.php";
$union=$_POST["union"];
$mouja=$_POST["mouja"];
$khatian=$_POST["khatian"];
$extra=$_POST["extra"];
$creator=$_SESSION["email"];
$c_date=(time());
$table="form";
mysql_query("INSERT INTO $table(`id`, `union`, `mouja`, `khatian`, `extra`, `creator`, `c_date`)
VALUES(NULL,'$union','$mouja','$khatian','$extra', '$creator', '$c_date')") or die(mysql_error());
$id = mysql_insert_id();
$sql="SELECT * FROM $table WHERE id='$id' AND creator='$creator'";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
header("Location: photo_upload.php?id=' . $row[0] . '");
?>
答案 0 :(得分:1)
您正在执行错误的字符串连接。您的最终字符串看起来像Location: photo_upload.php?id=' . 13 . '
。使用其中一个代码来连接字符串:
header("Location: photo_upload.php?id=".$row[0]);
header("Location: photo_upload.php?id={$row[0]}");
header('Location: photo_upload.php?id='.$row[0]);
答案 1 :(得分:0)
header("Location: photo_upload.php?id=' . $row[0] . '");在$ row [0]周围有额外的空格和点,这些空格和点被urlencoded到
%27%20.%2013%20.%20%27修剪额外的点和空格以获得photo_upload.php?id = 13 < p>
答案 2 :(得分:0)
你可以通过以下方式修复它:
header("Location: photo_upload.php?id=".$row[0]);
如果您获得了身份证明,请使用urldecode($_GET['id']);
将其删除。