重慶分公司,新征程啟航
為企業提供網站建設、域名注冊、服務器等服務
為企業提供網站建設、域名注冊、服務器等服務
支持插入中文的前提是:你的數據庫編碼和mysql連接所使用的字符集要相同,即:你的數據庫(comment)的字符集是GBK的,那么你在數據庫連接(mysql_connect)時要加上一句mysql_query('set
10多年的東城網站建設經驗,針對設計、前端、開發、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。成都營銷網站建設的優勢是能夠根據用戶設備顯示端的尺寸不同,自動調整東城建站的顯示方式,使網站能夠適用不同顯示終端,在瀏覽器中調整網站的寬度,無論在任何一種瀏覽器上瀏覽網站,都能展現優雅布局與設計,從而大程度地提升瀏覽體驗。創新互聯從事“東城網站設計”,“東城網站推廣”以來,每個客戶項目都認真落實執行。
names
gbk');
這樣的話就不會出現中文插入時出現亂碼現象。UTF8字符集時與GBK同理。
還有疑問?
有兩種方法...你試一下...不行的話加我的QQ
76558882
1.
修改
mysql
安裝目錄下的
my.ini
修改
default-character-set=latin1
把latin1
改為
gb2312
或
gbk
注意:
修改兩處
CLIENT
SECTION
#
----------------------------------------------------------------------
#
#
The
following
options
will
be
read
by
MySQL
client
applications.
#
Note
that
only
client
applications
shipped
by
MySQL
are
guaranteed
#
to
read
this
section.
If
you
want
your
own
MySQL
client
program
to
#
honor
these
values,
you
need
to
specify
it
as
an
option
during
the
#
MySQL
client
library
initialization.
#
[client]
port=3306
[mysql]
default-character-set=latin1
//把
latin1
改為
gb2312或
gbk
#
SERVER
SECTION
#
----------------------------------------------------------------------
#
#
The
following
options
will
be
read
by
the
MySQL
Server.
Make
sure
that
#
you
have
installed
the
server
correctly
(see
above)
so
it
reads
this
#
file.
#
[mysqld]
#
The
TCP/IP
Port
the
MySQL
Server
will
listen
on
port=3306
#Path
to
installation
directory.
All
paths
are
usually
resolved
relative
to
this.
basedir="C:/Program
Files/MySQL/MySQL
Server
5.0/"
#Path
to
the
database
root
datadir="C:/Program
Files/MySQL/MySQL
Server
5.0/Data/"
#
The
default
character
set
that
will
be
used
when
a
new
schema
or
table
is
#
created
and
no
character
set
is
defined
default-character-set=latin1
//將latin1
改為
gb2312
或
gbk
2.
進入在命令提示符下登錄mysql
輸入
charset
gb2312
你再嘗試使用
insert
into
插入一條記看看...
查詢前先加一句。并且統一所有編碼。
MYSQL_QUERY('SET NAMES GBK')
應該可以直接插入漢字的 你注意看看你的mysql的編碼。一般在安裝mysql的時候會提示你使用什么編碼,選擇適用中文的字符編碼即可。