关于php写数据库乱码有关问题

WBOY
Release: 2016-06-13 12:17:53
Original
775 people have browsed it

关于php写数据库乱码问题
在php页面内插入数据到数据库后,数据库内显示乱码。
数据库字符集:


页面字符集:


在插入前执行mysql_query("set names 'utf8'")能解决问题
网上说set names 'utf8'就是将character_set_connection,character_set_result,character_set_client设置成utf8,
但是我已经将数据库的所有字符集都设置成了utf8,却还是会乱码
另外,在前端插入中文乱码,在后台直接插入中文不会乱码。
想知道哪里还有问题,求各位大神解答

------解决思路----------------------
只要你的数据库安装时没有选择 utf8 
那么 mysql_query("set names 'utf8'") 总是必要的
------解决思路----------------------
只要你的数据库安装时没有选择 utf8 
那么 mysql_query("set names '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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!