请大家看一下这个是什么原因造成的?

kunfu 2004-08-09 09:34:14
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at F:\VIP\www.kfgj.com\cn\include\TMP5bsdq26ldx.php:8) in F:\VIP\www.kfgj.com\cn\include\TMP5bsdq26ldx.php on line 29

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at F:\VIP\www.kfgj.com\cn\include\TMP5bsdq26ldx.php:8) in F:\VIP\www.kfgj.com\cn\include\TMP5bsdq26ldx.php on line 29
...全文
132 点赞 收藏 12
写回复
12 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
surfchen 2004-08-10
前面加ob_start();
后面加ob_end_flush();
回复
kunfu 2004-08-10
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>counter</title>
</head>

<body>
<font color="#777A7D"><?php print(date("Y-m-d h:i:s A")); ?><?php echo " IP是".$REMOTE_ADDR.""; ?>
<?php
// *** Visit Counter ***
// FELIXONE 2002 - SB by Felice Di Stefano - www.felixone.it
$FX_digit = 9;
$FX_dpath = "FX_DataCounter";
$FX_fpath = "FX_DataCounter/counter.txt";
// Check if directory and file exists, if not create it.
if (!file_exists($FX_fpath)) {
if (!is_dir($FX_dpath)) {
mkdir($FX_dpath, 0700);
}
$FX_fso = fopen($FX_fpath,"w");
flock($FX_fso, 2);
fputs($FX_fso, 0);
flock($FX_fso, 3);
fclose($FX_fso);
}
// Read file and update it once per session
$FX_fso = fopen($FX_fpath,"r+");
$FX_count = fgets($FX_fso, 4096);
if (!session_id()) session_start();
if (!isset($HTTP_SESSION_VARS["FX_DataCounter"])) {
fseek($FX_fso, 0);
flock($FX_fso, 2);
fputs($FX_fso, $FX_count+1);
flock($FX_fso, 3);
fclose($FX_fso);
$FX_count++;
$FX_DataCounter = $FX_count;
session_register("FX_DataCounter");
}
// Add leadings
$FX_numlength = strlen((string) $FX_count);
if ($FX_numlength < $FX_digit) {
$FX_lead = (int) $FX_digit - $FX_numlength;
for ($i=0; $i<$FX_lead; $i++) {
$FX_count = "0" . $FX_count;
}
}
?>
共<?php echo $FX_count ?>人浏览
<?php
//首先你要有读写文件的权限
//本程序可以直接运行,第一次报错,以缶涂梢?
$online_log = "count.dat"; //保存人数的文件,
$timeout = 30;//30秒内没动作者,认为掉线
$entries = file($online_log);

$temp = array();

for ($i=0;$i<count($entries);$i++) {
$entry = explode(",",trim($entries[$i]));
if (($entry[0] != getenv('REMOTE_ADDR')) && ($entry[1] > time())) {
array_push($temp,$entry[0].",".$entry[1]."\n"); //取出其他浏览者的信息,并去掉超时者,保存进$temp
}
}

array_push($temp,getenv('REMOTE_ADDR').",".(time() + ($timeout))."\n"); //更新浏览者的时间
$users_online = count($temp); //计算在线人数

$entries = implode("",$temp);
//写入文件
$fp = fopen($online_log,"w");
flock($fp,LOCK_EX); //flock() 不能在NFS以及其他的一些网络文件系统中正常工作
fputs($fp,$entries);
flock($fp,LOCK_UN);
fclose($fp);

echo " 有".$users_online."人在线";

?>
</font>
</body>
</html>
回复
lzkd 2004-08-10
嗯,不贴出来的话,很难知道的
回复
tod204 2004-08-10
最好把你的前面的30行贴出来.看看...大家就好帮你改
回复
tod204 2004-08-10
在session_start()前不要有任何html的输出..
回复
pswdf 2004-08-10
session_start();之前不要有输出(echo)之类的。

连空行都要注意。
回复
kunfu 2004-08-10
不行啊哥们.
回复
tod204 2004-08-10
<?php
// *** Visit Counter ***
// FELIXONE 2002 - SB by Felice Di Stefano - www.felixone.it
$FX_digit = 9;
$FX_dpath = "FX_DataCounter";
$FX_fpath = "FX_DataCounter/counter.txt";
// Check if directory and file exists, if not create it.
if (!file_exists($FX_fpath)) {
if (!is_dir($FX_dpath)) {
mkdir($FX_dpath, 0700);
}
$FX_fso = fopen($FX_fpath,"w");
flock($FX_fso, 2);
fputs($FX_fso, 0);
flock($FX_fso, 3);
fclose($FX_fso);
}
// Read file and update it once per session
$FX_fso = fopen($FX_fpath,"r+");
$FX_count = fgets($FX_fso, 4096);
if (!session_id()) session_start();
if (!isset($HTTP_SESSION_VARS["FX_DataCounter"])) {
fseek($FX_fso, 0);
flock($FX_fso, 2);
fputs($FX_fso, $FX_count+1);
flock($FX_fso, 3);
fclose($FX_fso);
$FX_count++;
$FX_DataCounter = $FX_count;
session_register("FX_DataCounter");
}
// Add leadings
$FX_numlength = strlen((string) $FX_count);
if ($FX_numlength < $FX_digit) {
$FX_lead = (int) $FX_digit - $FX_numlength;
for ($i=0; $i<$FX_lead; $i++) {
$FX_count = "0" . $FX_count;
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>counter</title>
</head>

<body>
<font color="#777A7D"><?php print(date("Y-m-d h:i:s A")); ?><?php echo " IP是".$REMOTE_ADDR.""; ?>
共<?php echo $FX_count ?>人浏览
<?php
//首先你要有读写文件的权限
//本程序可以直接运行,第一次报错,以缶涂梢?
$online_log = "count.dat"; //保存人数的文件,
$timeout = 30;//30秒内没动作者,认为掉线
$entries = file($online_log);

$temp = array();

for ($i=0;$i<count($entries);$i++) {
$entry = explode(",",trim($entries[$i]));
if (($entry[0] != getenv('REMOTE_ADDR')) && ($entry[1] > time())) {
array_push($temp,$entry[0].",".$entry[1]."\n"); //取出其他浏览者的信息,并去掉超时者,保存进$temp
}
}

array_push($temp,getenv('REMOTE_ADDR').",".(time() + ($timeout))."\n"); //更新浏览者的时间
$users_online = count($temp); //计算在线人数

$entries = implode("",$temp);
//写入文件
$fp = fopen($online_log,"w");
flock($fp,LOCK_EX); //flock() 不能在NFS以及其他的一些网络文件系统中正常工作
fputs($fp,$entries);
flock($fp,LOCK_UN);
fclose($fp);

echo " 有".$users_online."人在线";

?>
</font>
</body>
</html>
这样看看...

回复
tod204 2004-08-10
这样你肯定错误..
在session start()以前下面的东西都不能有:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>counter</title>
</head>

<body>
<font color="#777A7D">
回复
kunfu 2004-08-09
俱体该怎么做?谢谢!
回复
kunfu 2004-08-09
是不是服务器的问题,我在本地测试为什么没有问题.
回复
多菜鸟 2004-08-09
session_start();之前不要有输出(echo)之类的。
回复
相关推荐
发帖
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
帖子事件
创建了帖子
2004-08-09 09:34
社区公告
暂无公告