Home > Backend Development > PHP Tutorial > How to solve mysql garbled code in php?

How to solve mysql garbled code in php?

烟雨青岚
Release: 2023-04-08 21:06:01
Original
2018 people have browsed it

How to solve mysql garbled code in php?

Solution to mysql garbled characters in php:

Add SET NAMES UTF8 after mysql_connect to eliminate garbled characters in UTF8 database. For GBK database, use SET NAMES GBK, the code is as follows:

$mysql_mylink = mysql_connect($mysql_host, $mysql_user, $mysql_pass); 
mysql_query("SET NAMES 'GBK'");
Copy after login

The database character set is utf-8

Use this for the connection statement:

mysql_query("SET NAMES 'UTF8'"); 
mysql_query("SET CHARACTER SET UTF8"); 
mysql_query("SET CHARACTER_SET_RESULTS=UTF8'");
Copy after login

Recommended tutorial: "php tutorial

The above is the detailed content of How to solve mysql garbled code in php?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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 Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template