Home> PHP Framework> YII> body text

Chinese garbled characters appear when the yii framework accesses the database

王林
Release: 2020-02-27 14:58:43
Original
2028 people have browsed it

Chinese garbled characters appear when the yii framework accesses the database

Problem:

The database encoding is utf8, and the Yii connection database encoding is also utf8, but the Chinese data retrieved is garbled.

Reason:

When entering the sql statement to insert Chinese data in the terminal, the environment is not utf8, so the data stored in the mysql database is not utf8 encoded, and the data taken out is garbled.

(Recommended tutorial:yii framework)

Solution:

When entering the sql statement to insert Chinese data in the terminal, you need to set the encoding first The environment is utf8, such as:

set names utf8
Copy after login

Just save the inserted data as utf8.

For more programming-related content, please pay attention to theProgramming Introductioncolumn on the php Chinese website!

The above is the detailed content of Chinese garbled characters appear when the yii framework accesses the database. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!