我知道这已被问了一百万次,但我已经通过所有的答案无济于事,因为我只有少量的代码,我想这是一个相对简单的修复(我希望)。令人沮丧的是,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