很急,高手请帮忙!问题解决马上结贴

418503 2003-12-08 01:47:39
以下程序运行时为什么会出现:
error,Cannot modify header information - headers already sent by (output started at D:\webs\autowebs\ocen\admin\include\functions.php:2) in D:\webs\autowebs\ocen\usersave.php on line 15
这样的错误?请帮忙,很急,谢谢!
<?
include("./admin/include/mysql.inc.php");
include("./admin/include/config.inc.php");
include("./admin/include/functions.php");

?>
<Script language="JavaScript" src="JavaScript.js"></Script>
<?
if ($account=="" or $Pass=="" or pass!=$passcheck or $name=="" or $pid=="" or $tel=="" or $email=="" or $addr=="" or netbarname=="" )
{
$eventid=EventLog("错误","注册资料非法",$account."帐号的".$name."注册资料为密码:".$Pass." 密码确认:".$passcheck." 身份证号:".$pid." 电话:".$tel." 电子邮件:".$email,"",$account,$sessionloginip);
header("location:PageInfo.asp?InfoType=RegErr&InfoNum=$eventid");
}else{
if( SaveData())
{
$eventid=EventLog("事件","用户成功注册",$Account."帐号的".$Name."注册为本站用户","",$Account,$sessionloginip);

}else{
$eventid=EventLog("错误","注册资料非法","帐号重复 帐号:".$account." 电子邮箱:".$email,"",$account,$sessionloginip);

?>
<Script language="JavaScript">
MsgBox("该帐号或电子邮件已经存在了!!\n请换一下再试试!");
window.history.go(-1);
</Script>
<?
}
}

function SaveData($info_talbe){
global $areaid,$account,$pass,$netbarname,$name,$pid,$tel,$email,$oicq,$addr;
global $db, $card_data_user_table;
$checkstr=GetCheckStr();

$sql="Select * from $card_data_user_table where account='$account' or email='$email'";
$db->query($sql);
if($db->num_rows()>0){

$sql="insert into $card_data_user_table(areaid,account,pass,netbarname,name,pid,tel,email,oicq,addr,addtime,userflag,usercheck) values ('$areaid','$account','$pass','$netbarname','$name','$pid','$tel','$email','$oicq','$addr','curdate()','0','$checkstr')";

$SaveData=true;
}else{
$SaveData=false;
}
return $SaveData;
}
?>
...全文
21 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
418503 2003-12-09
  • 打赏
  • 举报
回复
试过了,不行呀
gejskggd 2003-12-09
  • 打赏
  • 举报
回复
会不会是多余的空格或是换行造成的呢?
418503 2003-12-09
  • 打赏
  • 举报
回复
up
418503 2003-12-08
  • 打赏
  • 举报
回复
up
分不够可以再加
418503 2003-12-08
  • 打赏
  • 举报
回复
TO:luxuezhu(卢冲)
functions.php的文件是:


<?

function EventLog($EventType,$EventName,$EventDescription,$CheckNum,$UserAccount,$UserIP)
{
global $db, $card_data_eventlog_table;

$sql = "insert into $card_data_eventlog_table(eventtype,eventname,eventdescription,checknum,useraccount,userip,addtime) values ('$EventType','$EventName','$EventDescription','$CheckNum','$UserAccount','$UserIP','ghjg')";
$db->query($sql);
$sql="select max(id) from $card_data_eventlog_table";
$db->query($sql);
return $EventLog=$db->f(id);
}


//////////////////////生成校号=============
function GetCheckStr()
{
global $sessionchecknum;
while(($authnum=rand()%10000)<1000);
return $sessionchecknum=$authnum;
}
function GetCheckImage($CheckStr)
{
/*
* Filename: authimg.php
* Author: hutuworm
* Date: 2003-04-28
* @Copyleft hutuworm.org
*/

//生成验证码图片
Header("Content-type: image/PNG");
srand((double)microtime()*1000000);
$im = imagecreate(58,28);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
$gray = ImageColorAllocate($im, 200,200,200);
imagefill($im,68,30,$gray);
//将四位整数验证码绘入图片
imagestring($im, 5, 10, 8, $CheckStr, $black);

for($i=0;$i<50;$i++) //加入干扰象素
{
imagesetpixel($im, rand()%70 , rand()%30 , $black);
}

ImagePNG($im);
ImageDestroy($im);

}

?>
luxuezhu 2003-12-08
  • 打赏
  • 举报
回复
根据这个错误
error,Cannot modify header information - headers already sent by (output started at D:\webs\autowebs\ocen\admin\include\functions.php:2) in D:\webs\autowebs\ocen\usersave.php on line 15
肯定是在header("location:PageInfo.asp?InfoType=RegErr&InfoNum=$eventid");
前面有输出
不如把functions.php也贴出来看看
418503 2003-12-08
  • 打赏
  • 举报
回复
up
418503 2003-12-08
  • 打赏
  • 举报
回复
TO:TO:xuzuning(唠叨)
再者Header("Content-type: image/PNG");这个语句是放在一个自定义函数中,没有执行这个函数则说明Header("Content-type: image/PNG");并没有被执行,应该也不会影响到usersave.php之中的header()
418503 2003-12-08
  • 打赏
  • 举报
回复
TO:xuzuning(唠叨)

那是不是要把Header("Content-type: image/PNG");这句改成:<meta http-equiv="Content-Type" content="iamge/PNG; charset=gb2312">放在图片输出文件的<head></head>之中呢?
xuzuning 2003-12-08
  • 打赏
  • 举报
回复
那就更没有理由了,难道你把这以后的输出都视为图片内容吗?
OutlawStar 2003-12-08
  • 打赏
  • 举报
回复
有兩點要注意
一;在Header前,不能有輸出語句,如Print,each等
二;在使用Header時,"<?php"這個語句必須在第一行.
418503 2003-12-08
  • 打赏
  • 举报
回复
TO:回复人: xuzuning(唠叨)
在functions.php 第2行处有输出中没有输出,只是在functions.php还有一个header()
是:Header("Content-type: image/PNG");
hpflying 2003-12-08
  • 打赏
  • 举报
回复
header函数执行时不能有输出语句
xuzuning 2003-12-08
  • 打赏
  • 举报
回复
functions.php 第2行处有输出
header函数执行时,不允许前面有输出

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧