Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the Chinese garbled code in PHP+MYSQL

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "PHP+MYSQL Chinese garbled code how to solve", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "PHP+MYSQL Chinese garbled how to solve" it!

Enter show variables like "character%" in console; the running result is as follows:

This problem can be solved by uniformly setting the 12356 lines of value above to GBK or UTF-8.

First, look at lines 1, 2 and 5.

Where MYSQL is used in PHP, execute "set names gbk" or "set name utf8" first.

Second, then look at the third line, which is character_set_database.

You can type alter database 'databasename' default character set gbk collate gbk_chinese_ci; or alter database' databasename' default character set utf8 collate utf8_general_ci; in mysql console to run.

Finally, there is the sixth line.

Open my.ini, find default-character-set, and change it to default-character-set=gbk or default-character-set=utf-8, in two places. If you can't find it, you can add it after [mysql] and [mysqld] respectively.

After you have done the above, you will OK.

Thank you for reading, the above is the content of "how to solve PHP+MYSQL Chinese garbled". After the study of this article, I believe you have a deeper understanding of how to solve this problem of PHP+MYSQL Chinese garbled, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report