跟大家请教一个关于php+mysql字符编码问题,谢谢

WBOY
Release: 2016-06-23 14:20:28
Original
1096 people have browsed it

想把网站设置成UTF8的,查了好多资料,道理也明白了,页面、程序、数据库字符编码得统一起来。道理是明白了,不知道具体该怎么做。

网站服务器空间租用的别人的,MYSQL配置我自己无法控制。


页面用的dreamweaver5设计的,默认编码正好是utf-8。其他还需要做些什么?


回复讨论(解决方案)

前端字符集和数据库保存的字符集没有直接关系。再说了,MySQL数据库支持多类型的字符集,只要你在安装的时候选择数据库的字符集为 UTF-8 即可,那么你的数据就会按照 UTF-8 保存到数据库。

数据库是人间的,你自然是不能去修改设置的
你可以做的是
1、建表的时候给中文字段加上连接校对 gbk_chinese_ci 或 utf8_general_ci
   告诉 mysql 用什么字符集存放数据
2、在连接数据库后,执行 set names gbk 或 set names utf8 指令
   告诉 mysql 用什么字符集与他交流

具体怎么给中文字段加链接校对?

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!