php出现乱码

来源:百度知道 编辑:UC知道 时间:2024/05/21 16:39:34
<?php

// <script src="discuz/discuz_js.php?new=8&post=3&hot=6"></script>

include "config.inc.php";
//==========================变量定义===============================
$titlelength = 20; //标题长度,按字节
$discuz_table = $tablepre."threads"; //discuz表名
$new = $HTTP_GET_VARS['new']; //最新发表显示标题数
$post = $HTTP_GET_VARS['post'];//最新回复显示标题数
$hot = $HTTP_GET_VARS['hot']; //回复最多显示标题数
//===========================字符截取函数(防乱码)=================

function m_substr($str,$start=0,$strlen) {
for($i=0;$i<$strlen;$i++)
if(ord(substr($str,$i,1))>0xa0) $j++;
if($j%2!=0) $strlen++;
$str=substr($str,0,$strlen);
return $str;
}

//===========================调用Discuz帖===========================
@mysql_pconnect($dbhost,$dbuser,$dbpw);
@mysql_select_db($dbname);
//论坛最新发表
$result=@mysql_

是不是数据库存放数据的编码跟浏览器默认的编码不一致
你写的“论坛最新发表”不是乱码 而取出的数据内容显示乱码

header("content-type:text/html ;charset='***'")
应该是编码不对
你试下,不知道可不可以

看文件保存的编码~~~

用netepod另存为看下...都不是同一编码

先看数据库用的是什么编码 要和网页的编码统一起来 默认好象是UTF8的