php 中文 无法写入 mysql,PHP中文字符无法插入到Mysql

I am using GET to pass parameters, succesful save data to mysql if the data is in english, but nothing insert if the data is in chinese.

I have detected the data encoding is utf-8, found out that using my macbook it works fine, but not working on ie. Strange, any idea what's wrong with it?

For example

query("insert into Info values ('".$email."','".$_GET['name']."')");

This not successful if $name is chinese. I have tried echo $_GET['name'] and display normally, howerver the data can't inserted to databse is blank.

query("insert into Info values ('".$email."','香港')");

This method successful insert data to database

解决方案

Firstly, you really should use POST for these operations.

Check to ensure that the column you are inserting into has the correct encoding - perhaps export the table structure for us to see if you're not sure.

As Daan said, you could try

query('SET NAMES UTF8');

Before your insert query.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值