<?php
//header('content-type:text/html;charset=gb2312');
if(isset($_POST[edit])){
include("config/conn.php");
$id=$_POST[id];
$email=$_POST[email];
$qq=$_POST[qq];
$code=$_POST[youbian];
$tel=$_POST[tel];
$truename=$_POST[truename];
$sfzh=$_POST[sfzh];
$dizhi=$_POST[dizhi];
$time=date("Y-m-d H:i:s");
$sql1="update tb_user set truename='$truename',email='$email',qq='$qq',youbian='$code',sfzh='$sfzh',dizhi='$dizhi',tel='$tel',regtime='$time' where id=".$id;
echo $sql1;
$rs=mysql_query($sql1) or die(mysql_error());
$row=mysql_fetch_array($rs);
if($row)
echo "成功";
//header("location:userinfo.php");
}
?>
当输入中文时输出
update tb_user set truename='闄堝崕',email='[email protected]',qq='[email protected]',youbian='1234567ffff',sfzh='ffff',dizhi='1234455555',tel='1234567890',regtime='2010-08-25 10:52:40' where id=5
  Incorrect string value: '\xE9\x99\x88\xE5\x8D\x8E' for column 'truename' at row 1请问下向红字处的乱码和Incorrect string value这两个地方怎么改改?

解决方案 »

  1.   


    iconv (gb2312 , uft-8, $truename )  把$truename 替换
      

  2.   

    感觉你的 SQL 语句里的字符串是 UTF-8 编码方式的,你可以先执行下面的语句,然后再执行你的查询语句
    SET NAMES UTF8■□■□■□■□■□■□■□■
    □             □
    ■  忍以明志 勤以致远  ■
    □             □
    ■□■□■□■□■□■□■□■
    基于CSDN论坛提供的插件扩展功能,自己做了个签名档工具,分享给大家,欢迎技术交流 :)