0

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";
    }

?>
4

2 に答える 2

1

これを試して。うまくいかない場合は教えてください

<?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";
    }
}
?>
于 2012-05-14T04:52:59.630 に答える
1

ここには十分な情報がありません。上記のファイルの名前は何ですか?そして、PHPコードはdownload.php何ですか?にリダイレクトはありincludes/inc.phpますか?

もちろん、header()呼び出しを削除してもエラーは発生しませんheader('Location: download.php...')。リダイレクトを行うのはそれです。

于 2012-05-14T04:54:50.707 に答える