Home > php教程 > php手册 > 解决php连接mysql出现乱码办法讲解

解决php连接mysql出现乱码办法讲解

WBOY
Release: 2016-06-13 10:39:03
Original
1191 people have browsed it

很多朋友在学习PHP初期,连接数据库读出或是写的时候总会出现乱码,今天小编在这儿告诉大家一个最简单的办法解决乱码问题

用phpmyadmin添加mysql数据库,然后用php操作数据库出现乱码的解决办法:
1:确认phpmyadmin用的mysql字符集为utf-8 unicode(utf8);mysql连接校对为utf8_general_ci,language为中文-chinese simplified
2:确认每个数据表的“整理为”utf8_general_ci;
3:在php连接mysql数据库后加个语句来指定数据库的字符集,
   例如:$conn=mysql_connect("localhost","root","你的密码"); //连接数据库
         mysql_query("set name utf8");

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template