可能重复:
PHP 已发送的标头
我有这个登录脚本,它在我的 wampserver 上运行良好,但是当我上传到我的虚拟主机时,我不断收到错误
警告:session_start() [function.session-start]:无法发送会话 cookie - 标头已由(输出开始于 /data/multiserv/users/988963/projects/2254894/www/admin/processor/login.php:1 ) 在第 2 行的 /data/multiserv/users/988963/projects/2254894/www/admin/processor/login.php
警告:session_start() [function.session-start]:无法发送会话缓存限制器 - 标头已发送(输出开始于 /data/multiserv/users/988963/projects/2254894/www/admin/processor/login.php:1 ) 在第 2 行的 /data/multiserv/users/988963/projects/2254894/www/admin/processor/login.php
警告:无法修改标头信息 - 标头已由 /data/multiserv/users/988963/ 中的(输出开始于 /data/multiserv/users/988963/projects/2254894/www/admin/processor/login.php:1)发送projects/2254894/www/admin/processor/login.php 第 20 行
下面是代码:
session_start();
ob_start();
extract($_POST);
include("../admin/includes/connect.php");
$query = "SELECT id,username,password FROM account WHERE username =
'$username' and password = '$password'";
$result = mysql_query($query) or die("unable to get query DB");
if ($row = mysql_fetch_array($result)) {
if ($row) {
extract($row);
// create session
$_SESSION['zen_user'] = 'J@0&fu#iEXHU';
header("location: ../account.php?id=$id");
exit();
} else {
echo "<script>alert('wrong username or password') ;
history.go(-1);</script>";
exit();
}
} else {
echo "<script>alert('wrong username or password') ; history.go(-1);
</script>";
exit();
}
ob_end_flush();