Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何从url中删除额外的%和数字?_Php_Mysql_Url - Fatal编程技术网

Php 如何从url中删除额外的%和数字?

Php 如何从url中删除额外的%和数字?,php,mysql,url,Php,Mysql,Url,我想在下一页url中获取id。但是有很多%和带有id的数字。例如:我的id应该在url后面13。但是它变得 如何删除%和额外数字 这是我的全部代码 <?php @session_start(); ?> <?php include "db.php"; $union=$_POST["union"]; $mouja=$_POST["mouja"]; $khatian=$_POST["khatian"]; $extra=$_POST["extra"]; $creator=$_SES

我想在下一页url中获取id。但是有很多
%
和带有id的数字。例如:我的id应该在url后面13。但是它变得

如何删除%和额外数字

这是我的全部代码

<?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] . '");

?>


您正在进行错误的字符串连接。最后一个字符串看起来像
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]);
标题(“Location:photo_upload.php?id='.$row[0].”;$row[0]周围有额外的空格和点,这些空格和点被URL编码为%27%20.%2013%20.%20%27修剪额外的点和点以获得照片上传。php?id=13

您可以通过以下方式进行修复:

%27%20.%2013%20.%20%27
header("Location: photo_upload.php?id=".$row[0]);
在哪里获得id,只需使用
urldecode($_get['id'])
将其删除

header("Location: photo_upload.php?id=".$row[0]);