Resolving incorrect character encoding when displaying MySQL database results after upgrade to PHP 5.3

前端 未结 3 556
天涯浪人
天涯浪人 2021-01-04 19:19

Issue Description

After upgrading PHP on our development server from 5.2 to 5.3, we\'re encountering an issue where data requested from our database and displayed

3条回答
  •  时光取名叫无心
    2021-01-04 19:56

    If you have made sure that both the tables, and the output encoding are UTF-8, almost the only thing left is the connection encoding.

    The reason for the change in behaviour when updating servers could be a change of the default connection encoding:

    [mysql]
    default-character-set=utf8
    

    However, I can't see any changes in the default encoding between versions, so if those were brand-new installs, I can't see that happening.

    Anyway, what happens if you run this from within your PHP query and output the results. Any differences to the command line output?

     SHOW VARIABLES LIKE 'character_set%';
     SHOW VARIABLES LIKE 'collation%'; 
    

提交回复
热议问题