PHP 乱码解决方面

1.数据库编码
ALTER DATABASE 'test' DEFAULT CHARACTER SET utf8 COLLATE utf8_bin

2.表category的编码该为utf8
ALTER TABLE 'category' DEFAULT CHARACTER SET utf8 COLLATE utf8_bin

3.修改字段的编码:
ALTER TABLE 'test' CHANGE 'dd' 'dd' VARCHAR( 45 ) CHARACTER
SET utf8 COLLATE utf8_bin NOT NULL
4.在连接数据库的语句中
mysql_connect('localhost','user','password');
mysql_select_db('my_db');
mysql_query("set names utf8;"); //select 数据库之后加多这一句

5.PHP页面开始第一句
header("content-type:text/html; charset=utf-8");

http://www.iteye.com/topic/461900

 

你可能感兴趣的:(PHP)