Home >Backend Development >PHP Tutorial >How to solve the Chinese garbled problem in php mysql table

How to solve the Chinese garbled problem in php mysql table

WBOY
WBOYOriginal
2016-07-25 08:54:331297browse
  1. create database zzjz CHARACTER SET gbk COLLATE gbk_chinese_ci;

  2. create table zz_employees (employeeid int unsigned not null auto_increment primary key,name varchar(13) not null, UpdateTime DateTime) Character Set GBK Collate GBK_CHINESE_CI; itemname varchar (12) not null) Character set gbk color gbk_chinese_ci; unsigned not null,item varchar(200) not null,primary key (itemid) ,

  3. FOREIGN KEY (itemid) REFERENCES zz_configitems(itemid) ON UPDATE CASCADE,FOREIGN KEY (employeeid) REFERENCES zz_employees(employeeid) ON UPDATE CASCADE ) CHARACTER SET gbk COLLATE gbk_chinese_ci;
Copy code
You can also specify the gbk encoding when creating the table.

Of course, you can also modify the character set of the database through the following command

    alter database da_name default character set 'charset'.
Copy code
The client sends it in gbk format, you can use the following configuration:

    SET character_set_client='gbk'
  1. SET character_set_connection='gbk'
  2. SET character_set_results='gbk'
Copy code
The above introduces the Chinese garbled problem in the data table in pyh mysql programming Solution ,I hope to be helpful.

Statement:
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