欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Mysql和网页显示乱码解决方法集锦

程序员文章站 2022-05-18 10:15:58
将数据插入到php?name=%ca%fd%be%dd%bf%e2" onclick="tagshow(event)" class="t_tag">...
将数据插入到php?name=%ca%fd%be%dd%bf%e2" onclick="tagshow(event)" class="t_tag">数据库的时候显示乱码及从php?name=%ca%fd%be%dd%bf%e2" onclick="tagshow(event)" class="t_tag">数据库读取出来的数据在网页上显示为乱码的问题,其实就是做到php?name=%ca%fd%be%dd%bf%e2" onclick="tagshow(event)" class="t_tag">数据库编码,网页编码及表的编码一致)!gbk2312与下同理

(1)设置数据库编码,  为了与国际接轨,一般都设置成utf-8
(2)数据表的设置,也设置成utf-8
(3)把你的网页编码也设置成utf-8,打开dreamweaver,(修改)--(页面属性)
(4)在你的php文件的第一行加上 header("content-type: text/html; charset=utf-8");
(5)在对数据进行操作之前应该先进行mysql_query('set names utf8');操作,然后再执行对数据的查询,更新,插入等