游.程 2015-08-05 14:15 采纳率: 0%
浏览 39

PHP Mysql:字符集

My Database has as

  • Default collation: utf8_unicode_ci
  • Default characterset: utf8

All of my Databases have:

  • Collation: utf8_unicode_ci

My Mainpage is saved as utf8, has utf8-meta-charset and a php utf8-header. So is my Ajax-loaded Page. However, characters like ä, ö, ü are displayed: "?"

If I set the names at the beginning of my mainpage

set names utf8 COLLATE 'utf8_general_ci'

The Ajax-loaded Content is correct but my mainpage ö,ü... are displayed "?" The Mainpage content is via mb_detect_encoding($str); still utf8...

Where should I look?

Note: Every Content is included via include_once So index.php->loged.php->content.php

  • 写回答

2条回答 默认 最新

  • 衫裤跑路 2015-08-05 14:25
    关注

    To get your site working with UTF-8:

    1. Set the charset to the php connection object (not to be confused with the database settings) $mysqliDb->set_charset('utf8');
    2. Encode the PHP page with UTF-8, this has to be done by your code editor.

    I tried to point out all important points in this short article.

    EDIT:

    For PDO the syntax to set the charset would be:

    $dsn = "mysql:host=$dbHost;dbname=$dbName;charset=utf8";
    $db = new PDO($dsn, $dbUser, $dbPassword);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂