php的header的问题

来源:百度知道 编辑:UC知道 时间:2024/05/06 07:04:57
使用header出错
错误
Warning: Cannot modify header information - headers already sent by (output started at D:\freeweb\xxyz\web\bbs\show_add.php:3) in D:\freeweb\xxyz\web\bbs\show_add.php on line 24

Warning: Cannot modify header information - headers already sent by (output started at D:\freeweb\xxyz\web\bbs\show_add.php:3) in D:\freeweb\xxyz\web\bbs\show_add.php on line 25

代码
<?php
$id = $_GET["id"];

//定位记录,读出
$conn=mysql_connect("db4free.net:3307","打死我也不说","打死你我也不说");
if(!$conn) die("error : mysql connect failed");
mysql_select_db("就不说",$conn);
$sql = "select * from receive where id=".$id;
$result = mysql_query($sql);
if(!$result) die("error: mysql query");

$num=mysql_num_rows($result);
if($num<1) die("error: no t

在header函数的前面 不要有输出 比如echo之类的

刚刚出现过这个问题,我的情况是,在header前面有输出,将header置于最前面

header 比较麻烦 前面不弄有输出
建议你使用
<? echo "<script>alert('提示文字');location='连接地址';</script>";?>