lsok

一 创建数据库时设置编码

GBK: create database test2 DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci;

UTF8: CREATE DATABASE `test2` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci


二 创建表时设置编码

create table categroy
(
cid unsigned int not null auto_increment,
name varchar(20) not null,
primary key(cid)
)ENGINE=MyISAM DEFAULT CHARSET=utf8;

 

三 插入数据时设置编码

$query = \'********\';
mysql_query("set names \'utf8\'");
mysql_query($query, $DB]));


四 设置页面编码

将页面的编码设置为UTF-8格式,代码如下:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

(另外,可通过在phpmyadmin中执行下面的语句查看表和字段的编码字符集,
show create table `表名`
show full columns from `表名`)

分类:

技术点:

相关文章:

  • 2021-08-02
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
猜你喜欢
  • 2021-07-24
  • 2021-12-24
  • 2021-10-16
  • 2022-01-10
  • 2022-12-23
  • 2022-02-07
  • 2022-02-08
相关资源
相似解决方案