utf-8存mysql,保存到mysql时出现UTF-8问题

My website is using charset iso 8859 1

when user post chinese character, it will be saved into the database as & # 2 0 3 2 0 ; & # 2 2 9 0 9 ; which will output as the chinese character when retrieved.

I need to set my website to UTF-8

when user post chinese character, it will be saved as some funky character in the mysql, and when retrieved, some characters are correct but some are wrong.

my question is, after i set to UTF-8, how to i make mysql save the text as # 2 0 3 2 0 ; & # 2 2 9 0 9 ; instead of funky chars.

i tried to use htmlentities. it's not working correctly.

my script is using

$message = htmlentities(strip_tags(mysql_real_escape_string($_POST['message']),''));

when it's saved to mysql it is like this 你好

when it's retrieved to be display is like this ä½ å¥½

解决方案

i been seeing lots of encoding related issues

the owner should google a bit before posting

general check list:

mysql table schema to use utf-8

mysql clients connection to use utf-8 mysql --default-character-set=utf8

php mysqli_set_charset to utf-8

html encoding to utf-8

putty, emac clients... to be in utf-8

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值