mysql不识别utf-8,如何摆脱utf-8中无法识别的字符? mysql / php

I have a mysql database that's set to utf-8.

I have set my php header to: header("Content-Type: text/html; charset=utf-8");

and in my html:

When I return anything that has round quotes or apostrophes, they show up as unrecognized characters (black diamond with a ? inside).

If I run utf8_encode () on the string I'm echoing out, it looks fine in Chrome, but shows a different weird character in Firefox. Is there something else I can do site-wide to make this work better?

(I've accessed the db with sequel pro and phpmyadmin)

解决方案

full utf-8 settings:

1) .htaccess

AddDefaultCharset utf-8

PHP_VALUE default_charset utf-8

2) after mysqli_connect() in php call this:

mysqli_query($this->link, 'SET character_set_client="utf8",character_set_connection="utf8",character_set_results="utf8"; ');

3) your DB should be created with "collation: utf8" charset; all fields in table also should be "collation: utf8"

4) your PHP files also should be created with utf8 charset

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值