UTF-8网页显示空间的问题
在本地环境程序正常
传到服务器上,先是错误提示
Warning: Cannot modify header information - headers already sent by
找到问题所在,其中了个包括文件含BOM
去掉后,没有了错误提示。。但显示空白页面
主文件和包含文件代码如下:
主文件
<?php include_once('admin/include/config_conn.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>首页 珠海市湘宇电器商行</title>
<SCRIPT LANGUAGE=javascript>
<!--
function movepic(){
try{
var str=marqueeStr.innerText;
var intLen1=str.length;
var intLen2=marqueeStr.offsetWidth;
var j=intLen2/intLen1;
var strTemp=marqueeStr.innerHTML;
if(j>1){
for(i=0;i<j;i++)
strTemp+=" "+marqueeStr.innerHTML;
}
marqueeStr.innerHTML=strTemp;
}
catch(e){}
}
//-->
<\/script>
<link href="images/style.css" rel="stylesheet" type="text/css" />
</head>
<body onload=movepic()>
<!--静态头部文件-->
<?php include_once('head.htm'); ?>
<table width="995" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#30740B">
<tr>
<td width="308" valign="top"><br />
<!--左边栏-->
<?php include_once('leftPage.php'); ?>
<br /></td>
<td width="687" valign="top"><br />
<table width="667" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="1%"><div align="right"><img src="images/r1.gif" width="9" height="8" /></div></td>
<td width="97%" bgcolor="#F6FBFB"></td>
<td width="2%"><img src="images/r2.gif" width="9" height="8" /></td>
</tr>
</table>
<table width="664" border="0" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td>
<marquee behavior="ALTERNATE" Direction="left" scrolldelay="200" id="marqueeStr" height="150" width="100%" loop="-1" truespeed onMouseOver="this.stop();" onMouseOut="this.start();">
<?php
$strSql = "select * from article where xycase=1 order by id desc limit 0,5";
$result = $conn -> query($strSql);
if ($result){
while ($row = $result -> fetch_assoc()){
$preg = "/src=\"(.+?)\"/";
preg_match_all ( $preg , stripslashes ( $row['content'] ), $aryImg );
echo ( "<a href='RentingSecondary.php?caseid=" . $row['id'] . "' title='" . stripslashes( $row['title'] ) . "' ><img height='140' width='200' border='0' src='" . $aryImg[1][0] . "' /></a> " );
}
}
?>
</marquee>
</td>
</tr>
</table>
<table width="667" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="1%"><div align="right"><img src="images/r4.gif" width="9" height="8" /></div></td>
<td width="97%" bgcolor="#F6FBFB"></td>
<td width="2%"><img src="images/r3.gif" width="9" height="8" /></td>
</tr>
</table>
<br />
<table width="667" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="images/r1.gif" width="9" height="8" /></td>
<td bgcolor="#F6FBFB"></td>
<td><img src="images/r2.gif" width="9" height="8" /></td>
</tr>
<tr>
<td bgcolor="#F6FBFB"></td>
<td bgcolor="#FFFFFF"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="638" height="34" background="images/rightPublic.gif" bgcolor="#F6FBFB"> <img src="images/rightUs.jpg" alt="关于我们" width="70" height="17" /></td>
</tr>
<tr>
<td height="246" bgcolor="#F6FBFB">
<div align="left" class="content">
<?php
$strSql = "select * from article where id=197";
$result = $conn -> query($strSql);
$row = $result -> fetch_assoc();
echo ( stripslashes ( $row['content'] ) );
?>
</div></td>
</tr>
</table></td>
<td bgcolor="#F6FBFB"></td>
</tr>
<tr>
<td><img src="images/r4.gif" width="9" height="8" /></td>
<td bgcolor="#F6FBFB"></td>
<td><img src="images/r3.gif" width="9" height="8" /></td>
</tr>
</table></td>
</tr>
</table>
<!--底部版权信息-->
<?php include_once('bottun.htm'); ?>
</body>
</html> ;
数据库连接包含文件
<?php
header("Content-Type: text/html; charset=utf-8");
$host = "localhost";
$user = "root";
$pass = "root";
$db = "root";
$db_charset = "utf8";
@ $conn = new mysqli($host,$user,$pass,$db);
if (mysqli_connect_error())
{
echo('Error:Could not connect to database. Please try again later.');
exit();
}
$conn -> query("SET character_set_connection=$db_charset, character_set_results=$db_charset, character_set_client=binary");
//操作信息跳转函数
function gotourl($message='',$url='',$title='')
{
$html ="<html><head>";
if(!empty($url)){
$html .="<meta http-equiv='refresh' content=\"3;url='".$url."'\">";
$html .="<link href='../templates/style.css' type=text/css rel=stylesheet>";
$html .="</head><body><br><br><br><br>";
$html .="<table cellspacing='0' cellpadding='0' border='1' width='450' align='center'>";
$html .="<tr><td bgcolor='#ffffff'>";
$html .="<table border='1' cellspacing='1' cellpadding='4' width='100%'>";
$html .="<tr class='m_title'>";
$html .="<td>".$title."</td></tr>";
$html .="<tr class='line_1'><td align='center' height='60'>";
$html .="<br><font color='red'>".$message."</font><br><br>";
$html .="系统将在3秒后返回<br><br>如果您的浏览器不能自动返回,请点击[<a href=".$url." target=_self>这里</a>]进入";
}else{
$html .="[<a href='#' onclick='history.go(-1)'>返回</a>]";
}
$html .="</td></tr></table></td></tr></table>";
$html .="</body></html>";
echo( $html );
exit();
}
?> ;
版大帮我看看是啥原因。。先谢谢了