php怎样把英文名字中的点号,保存到数据库中?如:戴维·卡梅伦
我之前试着保存过,但不成功。只能保存“戴维”,后面的内容就丢失了。
还有一个问题,“黄粿”这个词,保存到数据库的时候,也是只保存个“黄”字,后面的内容就丢失了。请问高人,这个问题怎么解决?
我的页面编码,数据库的编码,都设置的是UTF-8。

解决方案 »

  1.   

    页面代码<tr>
                            <td width="20%">客户信息:</td>
                            <td>
                                <textarea id="customermsg" name="customermsg" cols="90" rows="5" style="border: 1px solid; border-color: #4DA0F4; margin-top: 10px; margin-right: 10px;"></textarea>
                            </td>
                        </tr>接收数据的代码:$text=$_POST["customermsg"];
        $accountId=$_POST["accountid"];
        $time=date("Y-m-d H:i:s");
        //获取用户id
        session_start();
        $userid=$_SESSION["uid"];    $information=new Information();
        $information->setUId($userid);
        $information->setAId($accountId);
        $information->setContent(addslashes(nl2br(trim($text))));
        $information->setTimes($time);    $bool=$information->addInformation($information);保存数据的代码:public function addInformation(Information $infor){
            include_once '../DAO/ConnectionDB.php';        ConnectionDB::connectDB();
            try{
                mysql_query("set names gb2312");
                $sql="insert into information (uId,aId,content,times) values ('$infor->uId','$infor->aId','$infor->content','$infor->times')";
                $bool=mysql_query($sql);
            }catch(Exception $e) {
                echo $e->getTraceAsString();
                echo iconv('utf-8','gb2312','添加信息失败!');
            }
            
            return $bool;
        }
      

  2.   

    数据库中,该字段的类型是longtext
      

  3.   

    页面编码,数据库的编码,都设置的是UTF-8
    为什么执行 mysql_query("set names gb2312");
      

  4.   

    表结构:
    CREATE TABLE `information` (
      `id` int(11) NOT NULL auto_increment,
      `uId` char(160) NOT NULL,
      `aId` char(160) NOT NULL,
      `content` longtext NOT NULL,
      `times` datetime NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=59 DEFAULT CHARSET=utf8;
      

  5.   


    LZ看这个UTF-8不显示字符,一定是你代码问题另外,从 echo iconv('utf-8','gb2312','添加信息失败!');貌似,你的页面编码,不是你所说的utf-8
      

  6.   

    ,,php文档时utf-8,但是网站前台是GBK吧?
      

  7.   

    如果我把mysql_query("set names gb2312");注释掉。保存到数据库后,会乱码
      

  8.   

     mysql_query("set names gb2312");
    让俺看着蛋疼!
      

  9.   

    要用 gbk 而不是 gb2312
      

  10.   

    mysql_query("set names 'GBK'");