我知道這已被問了一百萬次,但我已經通過所有的答案無濟於事,因爲我只有少量的代碼,我想這是一個相對簡單的修復(我希望)。令人沮喪的是,php文件在一臺服務器上完美工作,而不是另一臺。PHP - 警告:無法修改標題信息 - 仍然卡住
我收到此錯誤:
Warning: Cannot modify header information - headers already sent by (output started at /home/thepcguy/public_html/ship_image/functions/function-redirect.php:1) in /home/thepcguy/public_html/ship_image/functions/function-redirect.php on line 9
與本文件
<?php require_once('../Connections/ships.php');
if ($_GET['shore'] == "1") {
header('Location: ../shore_establishment.php?ship_id=' .urlencode($_GET['ship_id']) . "&shore=1" . "&page=ship");
//echo"first";
} else if ($_GET['shore'] == "0") {
header('Location: ../shipinfo.php?ship_id=' .urlencode($_GET['ship_id']). "&shore=0" . "&page=ship");
//echo"second";
};
?>
爲了利益着想,文件ships.php是:
<?php
$hostname_ships = "xxxxx";
$database_ships = "xxxxx";
$username_ships = "xxxxx";
$password_ships = "xxxxx";
$ships = mysql_pconnect($hostname_ships, $username_ships, $password_ships);
?>
我會檢查一個,但我看過幾個結果。謝謝 – user2406993
function-redirect.php的第9行是什麼?你確定你在ship.php中沒有任何輸出(甚至是空格)? –
在你的一個文件的開頭或結尾可能有一個空格,你也想在設置你的重定向後用'die'結束當前腳本。 – cmorrissey