PHP SQL 中文乱码

WBOY
Release: 2016-06-23 14:11:14
Original
1105 people have browsed it

首先声明,IE浏览器编码格式跟数据库的整理者都被设置成“UTF-8”了。同样,按照这个打印也没问题。但是结果是,显示在网页上是正常的,但是插入数据库中的信息却是乱码。上图如下。


回复讨论(解决方案)

mysql_query("set names utf8"); //执行插入前加上这句



这是在浏览器中打印出来的东西,第一张图第一行的print_r打印出来的。编码也是UTF-8。可是为啥数据库就出问题了?想不通……求大神

1.文档流:header("Content-type:text/html;charset=utf-8");

2.数据库:$pdo->query(‘SET NAMES UTF8’);

3.PHP脚本文件:utf-8无BOM格式。

这三项都做到,不可能乱码的。

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
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!