header()を使用するとリダイレクトループエラーが発生します。mysql_num_rows();の後 header();を置き換えた場合 エコーを使用すると、リダイレクトループエラーは発生しません。
<?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";
}
?>