为什么包含“垟”字的内容保存mysql数据库出错?错误提示为:Fatal error: Uncaught exception 'Exception';如果把这个字去掉,就可以保存进去了。

解决方案 »

  1.   

    这个错误和哪个字没关系也和mysql无关,是php的错误。把错误所在行的附近代码贴上来看看
      

  2.   

    $jxjmysql->query("update ".$tabname." set content='垟' where id='5'");
    这样就出错:Fatal error: Uncaught exception 'Exception' with message 'Incorrect string value: '\x88\x94' for column 'content' at row 1 in SQL$jxjmysql->query("update ".$tabname." set content='羊' where id='5'");
    这样就可以,不会出错!
      

  3.   

    $content = mysql_escape_string('羊');
    $jxjmysql->query("update ".$tabname." set content='{$content}' where id='5'");
    这样先试试,至于为什么会这样我也不知道,很奇怪,坐等高人
      

  4.   

    你的数据库的编码是 gb2312 的,当然不能保存 “垟”
    因为“垟”是 gbk 字符
      

  5.   

    错误信息中
    Fatal error: Uncaught exception 'Exception' with message 'Incorrect string value: '\x88\x94' for column 'content' at row 1 in SQL的 \x88\x94 是 垟 的GBK内码如果程序文件是 utf-8 编码的,那么 gbk 编码的文字从哪里来的?
      

  6.   

    用mb_detect_encoding检测,已经是utf8了
      

  7.   

    本帖最后由 xuzuning 于 2012-03-28 14:33:36 编辑
      

  8.   

    把数据库编码设为gbk,php编码也gbk,就可以了。中文网站还是gbk比较通用。