免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 2969 | 回复: 17
打印 上一主题 下一主题

headers already been sent ,这个问题怎么解决 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-05-22 17:31 |只看该作者 |倒序浏览
我在编译程序时,
header information - headers already sent by (output started …………
这是由于headers_sent()这个函数的值为真,导致的,
但我怎么能避免这种错误,还是我的配置有问题
他和php。ini中的output buffering 又 有什么关系?

论坛徽章:
0
2 [报告]
发表于 2003-05-23 12:06 |只看该作者

headers already been sent ,这个问题怎么解决

; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit.  You can enable output buffering during runtime by calling the output
; buffering functions.  You can also enable output buffering for all files by
; setting this directive to On.  If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of 'On', as
; a value for this directive (e.g., output_buffering=4096).

//缓冲这样就可以了
output_buffering = on

论坛徽章:
0
3 [报告]
发表于 2003-05-23 12:46 |只看该作者

headers already been sent ,这个问题怎么解决

呵呵,,session 前不能有输出

论坛徽章:
0
4 [报告]
发表于 2003-05-23 13:42 |只看该作者

headers already been sent ,这个问题怎么解决

output_buffering = on
这一项我已经是改为on了
但是还不成,
我还是不太明白session 前不能有输出 是什么意思?
能不能请高手讲的再详细一些呐?

论坛徽章:
0
5 [报告]
发表于 2003-05-23 14:03 |只看该作者

headers already been sent ,这个问题怎么解决

if ($Ok) {

  //  用户的昵称必须填的
  if (!$nicker) $error="用 户 名 不 能 为 空";

  // 用户的昵称只能使用小写字母“a-z”,数字“0-9”,和下划线“_”
  if ((!isset($error)) and (!ereg("[_0-9a-z]*",$nicker))) $error="请 使 用 小 写 字 母“a-z”,数 字 “0-9”,和 下 划 线 “_”";

  //用户的昵称必须大于三位
  if ((!isset($error)) and (strlen($nicker)<4)) $error="昵称的长度应大于3位";

  //该昵称已被注册了
  if ((!isset($error)) and (Checknicker($nicker))) $error="此 用 户 名 已 存 在";

  //  请输入密码
  if ((!isset($error)) and (!$password)) $error="请 输 入 您 的 密 码";

  //两次输入的密码不同
  if ((!isset($error)) and ($password!=$password2)) $error="两 次 输 入 的 密 码 不 同";
  //如果通过检查就开始添加用户
  if (!isset($error)) {
    //  注册新用户
    AddUser();
    //  成功页面
    header("Location: login_ok.php?id=$id\n";
  } else
  //否则报错
  {
    //  失败页面
    header("Location: login_error.php?error=$error\n";
  }
  exit;
}
?>;
<?
/********************************
*下面是用户的输入表单           *
*当输入完后再次调用本程序       *
*以进行错误检查和用户的添加     *
*********************************/
include "header.inc.php";
//缺省的性别是“男”
$gender="M"
?>;

<BODY>;
<!--用户申请表的标题-->;
<TABLE width=100% border=0 align=center>;
  <TR class=myBlue>;
    <TD height=25 align=center>;
        <FONT class=myRed>;
         <?echo "用 户 申 请 表"?>;
        </FONT>;
    </TD>;
  </TR>;
</TABLE>;         

<hr color=red>;
<!--以下是用户申请的表单-->;
<FORM METHOD="OST" ACTION="<? echo $PHP_SELF; ?>;">;
…………
</FORM>;
</BODY>;
</HTML>;

论坛徽章:
0
6 [报告]
发表于 2003-05-23 14:10 |只看该作者

headers already been sent ,这个问题怎么解决

如上所示,为程序的部分代码?
所要实现的功能是:
通过下方的form把注册信息传到上方的php程序,
adduser()这个函数已定义且肯定没问题,
只是到了header()这里想进行跳转的时候,总是说
Warning:Cannot modify information - headers already sent by (output started at /apache/register.php:2) in /apache/register.php online98
试问是我的程序有问题,还是我的php的配置出了问题,
对于各位浏览本页的高手,小弟万分感谢!!

论坛徽章:
0
7 [报告]
发表于 2003-05-23 15:57 |只看该作者

headers already been sent ,这个问题怎么解决

header()前不能有输出。

论坛徽章:
0
8 [报告]
发表于 2003-05-23 17:04 |只看该作者

headers already been sent ,这个问题怎么解决

但是对于如下程序也是同样的错误
<html>;
<head>;
<title>;header</title>;
</head>;
<body>;
<?
header("location:http://www.baidu.com/";
?>;
</body>;
</html>;


这又怎么办呐?

论坛徽章:
0
9 [报告]
发表于 2003-05-24 01:32 |只看该作者

headers already been sent ,这个问题怎么解决

当然错了,前面有输出了。

论坛徽章:
0
10 [报告]
发表于 2003-05-24 15:11 |只看该作者

headers already been sent ,这个问题怎么解决

我今天试过了,这个程序又能用了,
上边的程序是对的,我可能是php的配置出了问题,昨天改完,今天启动机器后,就可以用了,但我还不太清楚是改了什么,导致的,
不过要谢谢你们这些好心人了,
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP