用php显示数据库的代码,报Warning: Cannot modify header information - headers already sent by
报Warning:Cannotmodifyheaderinformation-headersalreadysentby(outputstartedatF:\XAMPP\h...
报Warning: Cannot modify header information - headers already sent by (output started at F:\XAMPP\htdocs\Untitled-2.php:119) in F:\XAMPP\htdocs\Untitled-2.php on line 135Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at F:\XAMPP\htdocs\Untitled-2.php:119) in F:\XAMPP\htdocs\conn.php on line 2
php代码如下:
<?php header("Content-Type: text/html; charset=gb2312");
include "conn.php";?>
<?php $sql=mysql_query("select gs,date from user order by id desc limit 5");
$result ="mysql_fetch_array($sql)";
while($result=mysql_fetch_array($sql)){
?>
<tr align="left" >
<td align="left"> <?php echo "<a href=content.php?id=".$result[id].">".$result[gs]."</a><br>";;?></td>
</tr>
<?php
}
?>
conn.php代码如下
<?php
session_start();
error_reporting(0);
$config = mysql_connect("localhost","root","");
mysql_select_db('test',$config);
mysql_query("set names 'gb2312'");
?>
我数据库名是text 表是user 展开
php代码如下:
<?php header("Content-Type: text/html; charset=gb2312");
include "conn.php";?>
<?php $sql=mysql_query("select gs,date from user order by id desc limit 5");
$result ="mysql_fetch_array($sql)";
while($result=mysql_fetch_array($sql)){
?>
<tr align="left" >
<td align="left"> <?php echo "<a href=content.php?id=".$result[id].">".$result[gs]."</a><br>";;?></td>
</tr>
<?php
}
?>
conn.php代码如下
<?php
session_start();
error_reporting(0);
$config = mysql_connect("localhost","root","");
mysql_select_db('test',$config);
mysql_query("set names 'gb2312'");
?>
我数据库名是text 表是user 展开
1个回答
2015-01-08
展开全部
追问
把header函数放在最前面后。网页显示的是乱码。第二个 文件格式不懂,是啥?
追答
第二个, 说起了还真有点麻烦!
那给你说说第一个问题
如果出现乱码, 那是你还有别的地方没有弄好!
无论乱码不乱码, header之前一定不能有任何输出, 这个是php本身的机制, 你无从改变!!!
如果你非要改, 程序运行一定不顺畅!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询