PHP的MySQL查询编码问题 [英] php mysql query encoding problem

查看:63
本文介绍了PHP的MySQL查询编码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于utf-8 encodin的页面. Mysql设置为utf8_general_ci. 这是查询:

I have a page with utf-8 encodin. Mysql is set to utf8_general_ci. Here is the query:

 mysql_query("SET CHARACTER SET utf8_general_ci");

               $query = "INSERT INTO newsbox VALUES ('null', '$zaglavie', '$nom_file_big', '$den', '$mesec', '$godina', '$zaglavie2', '$text', '$zaglavie3')";
                $result = mysql_query($query) or die(mysql_error()); 

并插入西里尔文输入文字,如?????.可能是什么问题.

and cyrillic input text is inserted like ?????. What could be the problem.

推荐答案

我不确定mysql_query("SET ..")是否按预期工作.尝试使用mysql_set_charset()设置字符集. 您确定文本是这样插入的吗?如果您使用的CLI mysql客户端使用了错误的字符集,则显示输出也可能有错误(也可能通过mysql_fetch _ *()进行检索).

I'm not sure if the mysql_query("SET ..") works as expected. Try setting the character set with mysql_set_charset(). Are you sure the text is inserted like that? If you're using the CLI mysql client with a wrong character set, display output may be faulty as well (that probably goes for retrieval via mysql_fetch_*() as well).

这篇关于PHP的MySQL查询编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆