PHP知识记录

WBOY
Release: 2016-06-23 13:46:10
Original
1017 people have browsed it

1、解决数据库前台显示乱码问题

在mysql_connect后面加一句SET NAMES UTF8,即可使得UTF8的数据库消除乱码,对于GBK的数据库则使用SET NAMES GBK,代码如下:

1 $mysql_mylink = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
2 mysql_query("SET NAMES 'GBK'");

数据库字符集为utf-8 

1 mysql_query("SET NAMES 'UTF8'");
2 mysql_query("SET CHARACTER SET UTF8");
3 mysql_query("SET CHARACTER_SET_RESULTS=UTF8'");

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