保存到mysql时出现UTF-8问题 [英] UTF-8 problem when saving to mysql
问题描述
我的网站正在使用charset iso 8859 1
My website is using charset iso 8859 1
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
当用户发布汉字时,它将作为& #2 0 3 2 0; & #2 2 9 0 9
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.
我需要将我的网站设置为UTF-8
I need to set my website to UTF-8
当用户发布中文字符时,它将被保存为一些有趣的字符在mysql中,当检索时,一些字符是正确的但有些是错误的。
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.
我设置为UTF-8之后,我如何使mysql保存文本为#2 0 3 2 0; & #2 2 9 0 9;而不是时髦的字符。
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.
我试图使用htmlentities。它不能正常工作。
i tried to use htmlentities. it's not working correctly.
我的脚本正在使用
$message = htmlentities(strip_tags(mysql_real_escape_string($_POST['message']),'<img><vid>'));
当它保存到mysql时,它就像这个ä½ å¥½
当它被检索到显示是这样ä½å¥½< ----是以前存储在mysql中的时髦字符
when it's saved to mysql it is like this ä½ å¥½ when it's retrieved to be display is like this ä½ å¥½ <---- is the funky character that is stored in mysql previously
推荐答案
我遇到很多编码相关问题
所有者在发布之前应该google一些。
i been seeing lots of encoding related issues the owner should google a bit before posting
一般检查列表:
- mysql表模式使用utf-8
- mysql客户端连接使用utf-8
mysql --default-character-set = utf8
- php
mysqli_set_charset
to utf-8 - html编码为utf-8
- putty,emac客户端...位于utf-8
- 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
这篇关于保存到mysql时出现UTF-8问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!