How to solve mysql garbled code in php?

烟雨青岚
Release: 2023-04-08 21:06:01
Original
1865 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:
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
Popular Tutorials
More>
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!