但是我也会在下面的代码中得到同样的错误......你能否请你分享你的建议..
错误:
警告:无法修改标头信息 - 已发送的标头 (输出从/home/stthohuu/public_html/sp/announcements.php:1开始) 在第45行的/home/stthohuu/public_html/sp/announcements.php
警告:无法修改标头信息 - 已发送的标头 (输出从/home/stthohuu/public_html/sp/announcements.php:1开始) 在/home/stthohuu/public_html/sp/announcements.php第46行
<?php
if(isset($_GET['id']))
{
ob_start();
// if id is set then get the file with the id from database
$con = mysql_connect('localhost', abc’, 'abc') or die(mysql_error());
$db = @mysql_select_db('stthohuu_church', $con);
$id = $_GET['id'];
$query = "SELECT name, type, size, content " .
"FROM newsletter WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);
header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");
ob_clean();
echo $content;
mysql_close();
exit;
}
?>
</head>
<body>
<?php
//database connection
$con = mysql_connect('localhost', abc', 'abc') or die(mysql_error());
//select database
$db = mysql_select_db('stthohuu_church', $con);
$query = "SELECT id, name FROM newsletter order by id desc";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
echo "No files found in DB<br>";
}
else
{
while(list($id, $name) = mysql_fetch_array($result))
{
?>
<a href="../archive_newsletter.php?id=<?php echo urlencode($id);?>"
><?php echo urlencode($name);?></a> <br>
<?php
}
}
mysql_close();
?>
</body>
</html>