如何存储字符如♥☆到DB? [英] How to store characters like ♥☆ to DB?
本文介绍了如何存储字符如♥☆到DB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
上一期 - 无法储存非英文字元:
这是通过使用UTF8修复的。但是今天意识到,像♥☆
的符号不能正确存储。它们会转换为♥¬〜†
的字符。
如何解决? >
解决方案
UTF8在整个频谱(MySQL,PHP,Apache,< meta&
$ query = update tbl set col ='♥☆'where id = 1;
mysql_query($ query)或die(mysql_error());
$ query =select col from tbl where id = 1;
$ res = mysql_query($ query)或die(mysql_error());
print_r(mysql_fetch_row($ res));
调试输出:
Content-type:text / html; charset = utf-8
Array
(
[0] =>♥☆
)
Previous issue - was not able to store non-english characters:
How to store non-english characters?
That was fixed by using UTF8. But realized today that symbols like ♥☆
are not stored correctly. They get converted to characters like ♥☆
.
How can this be fixed?
解决方案
Is UTF8 used consistently across the whole spectrum (MySQL, PHP, Apache, <meta>s, headers..)?
For me this worked out of the box:
$query = "update tbl set col = '♥☆' where id = 1";
mysql_query($query) or die(mysql_error());
$query = "select col from tbl where id = 1";
$res = mysql_query($query) or die(mysql_error());
print_r(mysql_fetch_row($res));
Debug output:
Content-type: text/html; charset=utf-8
Array
(
[0] => ♥☆
)
这篇关于如何存储字符如♥☆到DB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文