dongxianghui3709 2014-01-25 12:16
浏览 135
已采纳

mysql插入和phpmyadmin中的中文字符

i have this chinese character which i want to insert into database and browser output in correct but when data is inserted into mysql it is in different format something like this.

my chinese characters

图片库,高清图片大全,图库

and inserted into database is

图片库,高清图片大全,图库

i have tried several things like setting utf8

     mysql_set_charset("utf8", $connection);

then chenaged the collation from swidish to utf general

then checked the details with this command which proved that my charcter is correctly set to utf8

   SHOW CREATE TABLE tablea;

   CREATE TABLE `tablea` (
   `id` int(12) NOT NULL AUTO_INCREMENT,
   `tiya` text CHARACTER SET utf8 NOT NULL,
   PRIMARY KEY (`id`),
  ) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

can anyone suggest where to solve chinese charracter issue .my insert is this

         mysqli_query ($con,"INSERT INTO tablea (tiya) VALUES ('$tit')");
  • 写回答

1条回答 默认 最新

  • duandang6352 2014-01-25 12:23
    关注

    All of your entire environment must be utf-8-capable. The file encoding of you php-file must be utf-8. The web server (apache?) must serve utf-8. Your mysql table must have utf-8 as charset. You connection(s) must be utf-8.

    If one in the chain is missing, you get the above results. Additionaly: if you tried to fiddle around with character conversion inbetween, this is probably mixed up entirely. Once the above chain is set up properly, no char conversion is needed at all.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)