php页面返回ajax中文值出现了显示乱码

2014 年 12 月 31 日3790

为了帮助网友解决“php页面返回ajax中文值出现了显示乱”相关的问题,中国学网通过互联网对“php页面返回ajax中文值出现了显示乱”相关的解决方案进行了整理,用户详细问题包括:/'.parent();td>//<<;
<table&gt:i;'
&lt.exe $operator $customerid $nowtime&quot.php部分代码
<<调用系统exe文件运算;table>/&gt.$rs['."<
$res = mysql_fetch_assoc($query);];
<;"

<记录当前时间

//td>'td>//"select * from custvalue where starttime='

&lt.$rs['
<custvalue.$rs['计算'
< value='.children('/center'futurevalue'
$sql=").php部分代码
<select>pastvalue'
"tr>];td width=148>td>+customerid).parent():userinfo name字段为gb2312

$query = mysql_query($sql).sel_customer'&quot?
$customerid=$_GET[customerid];/calculate(this)'
$query = mysql_query($sql);text/td width=148>
&lt.$nowtime;tr&gt.&quot.next();; /
/."
&lt."/<b; /tr>];/select>

}

b;td>td&gt:s'查询程序运行后的数据根据时间

$sql = ";这里输出的$name 乱码

$nowtime = date('<select * from userinfo where id='table width=100% >.php;获取id

$(t).operator;注意;"<
echo $name;;];> /option value=');tr align='/
$name=$res[name];&gt.load("
&lt.val();

;/
function calculate(t){
var customerid = $(t);</
echo "UserID'td>;);script type="</
<
$rs = mysql_fetch_assoc($query);option>&lt?>Y-m-d H;//><
<

<
<; /td width=148&gt?customerid="td>input type=button onclick='table>td>
$operator=$_SESSION[',运算保存数据库

system("javascript"/.&quot.prev();"remark'"";第一个页面
a,具体解决方案如下:

解决方案1:
<

解决方案2:
数据库的编码有两种gbk 和 gb2312
我设置过三种

header("Content-Type:text/html;charset=gbk");
mysql_query("set names 'gbk'");
$name= iconv("gb2312","gbk",$name);
结果返回出来的值还是乱码的

解决方案3:
GBK 涵盖GB2312所以无需单独设置或转换.数据库连接更无需发送header

问题估计出在你的数据库编码上,建议你去下载一个phpmyadmin去看看你的数据库里,数据库编码,数据表编码,字段编码三者是否一致,以及在phpmyadmin里数据能否正常显示.

解决方案4:
感谢这位网友的解答

乱码已经解决了,我把页面的编码改为

header("Content-Type:text/html;charset=gb2312");
$name= iconv("gbk","gb2312",$name);

解决方案5:
谢谢

0 0