mysql编码问题
当我将外语内容插入数据库时,我遇到了问题。 我已将数据库的排序规则设置为utf8_general_ci(也尝试utf8_unicod_ci)。 但是当我将一些文本插入表中时,它是这样保存的
Õ€Õ¡ÕµÕ¥Ö€Õ¥Õ¶ Ô±Õ¶Õ¸Ö‚Õ¶
但是当我从数据库读取时,文本以正确的形式显示。它看起来像只在数据库中。
我已将 html 文档中的编码设置为 charset=UTF-8
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
进行设置
mysql_query("SET NAMES UTF-8");
mysql_query("SET CHARACTER SET UTF-8");
并在连接到数据库时 。 所以我认为我已经完成了所有操作,但它仍然以已知的格式保存。 你能帮我吗? 提前致谢
i have a proble, when insert something in foreign language into database.
i have set the collation of database to utf8_general_ci(try utf8_unicod_ci too).
but when i insert some text into table, it was saved like this
Õ€Õ¡ÕµÕ¥Ö€Õ¥Õ¶ Ô±Õ¶Õ¸Ö‚Õ¶
but when i read from database, text shows in correct form. it looks like that only in database.
i have set encoding in my html document to charset=UTF-8
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
and i set
mysql_query("SET NAMES UTF-8");
mysql_query("SET CHARACTER SET UTF-8");
when conecting to database.
so i think that i' ve done everything, but it still save in that anknown format.
could you help me.
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信你必须在MySQL中
SET NAMES utf8
,而不是UTF-8
。I believe you have to
SET NAMES utf8
, instead ofUTF-8
, in MySQL.看起来您的 phpmyadmin 可能没有使用正确的字符集。在 phpmyadmin 文件夹中,打开 config.default.php 并编辑行
到您选择的编码。
It looks like maybe your phpmyadmin isn't using the correct charset. In your phpmyadmin folder, open config.default.php and edit the lines
To your chosen encoding.
建议使用
mysql_set_charset()
而不是“SET NAMES”查询,但影响应该是相同的。It is suggested to use
mysql_set_charset()
instead of "SET NAMES" query, however the impact should be the same.