我在使用 header() 时遇到重定向循环错误;在 mysql_num_rows() 之后;如果我替换 header(); with echo 没有重定向循环错误。
<?php
require("includes/inc.php");
$id = trim(sanitize($_GET['id'])); //Receives the id of the file from the url
$fileid = mysql_query("SELECT * FROM files WHERE fileid = '$id'");
if (mysql_num_rows($fileid) != 1) {
header('Location: download.php?error=invalid_file');
} else {
echo "File Exist";
}
?>
最佳答案
试试这个。如果不起作用请告诉我
<?php
require("includes/inc.php");
$id = trim(sanitize($_GET['id'])); //Receives the id of the file from the url
if($id)
{
$fileid = mysql_query("SELECT * FROM files WHERE fileid = '$id'");
if (mysql_num_rows($fileid) != 1) {
header('Location: download.php?error=invalid_file');
} else {
echo "File Exist";
}
}
?>
关于php - mysql_num_rows();和标题();给出重定向循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10577644/