0

Possible Duplicate:
UTF-8 all the way through

I'm trying to insert special characters (like é etc.) in a MySQL database but when I insert through a query, in the database it appears as: "é". When I insert the query directly in Phpmyadmin, it works as it should. I have already set the collection charset to utf8_unicode_ci. I have this in my HTML:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

How can I fix this? (I already googled it, but I only found the collection things, that won't work..)

(jQuery because I'm sending it with a $.POST)

4

3 回答 3

1

确保与数据库的连接也使用此字符集:

$conn = mysql_connect($server, $username, $password);
mysql_set_charset("UTF8", $conn);

看到这个答案:答案

于 2012-10-21T19:17:47.903 回答
1

您的数据库连接是使用 utf8 吗?

初始化数据库连接时尝试运行此 sql:

SET NAMES 'utf8';

我建议你也通读一下

于 2012-10-21T19:16:27.810 回答
0

试着做

mysqli_query('SET NAMES utf8');

连接数据库后。
根据手册,SET NAMES 表示客户端将使用什么字符集向服务器发送 SQL 语句。因此,SET NAMES 'utf8' 告诉服务器将来来自客户端的传入消息将采用 utf8 编码。它还指定服务器用于将结果发送回客户端的字符集。

于 2012-10-21T19:17:54.747 回答