简体   繁体   English

MySQL查询行为奇怪?

[英]mysql query behaving strangely?

I have a my sql query 我有一个SQL查询

INSERT INTO question (instruction_id, test_id, question,option1,option2,option3,option4,option5,option6,answer) VALUES ('0','1',' निम्न में से कौन सा मीडिया प्रकार सबसे अधिक जानकारी धारित कर सकता है? ','  ब्लू-रे    ',' सीडी    ',' डीवीडी ',' फ्लॉपी डिस्केट   ',' इनमें से कोई नहीं','','2')

I am running it from my application and from phpmyadmin. 我正在从我的应用程序和phpmyadmin运行它。 From my application options are not added everything before option1 and everything after option6 is getting added. 从我的应用程序中,未添加option1之前的所有内容以及option6之后的所有内容。 But when i am running the query from phpmyadmin its working perfectly. 但是,当我从phpmyadmin运行查询时,它运行正常。 What can be the possible reason for this issue 此问题的可能原因是什么?

I believe this is because you are not setting the unicode references correctly in your php page, however phpmyadmin has it set correctly so it handles your characters. 我相信这是因为您没有在php页面中正确设置unicode引用,但是phpmyadmin设置正确,因此它可以处理您的字符。 Use: 采用:

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

or set it in php using: 或使用以下命令在php中进行设置:

header( 'Content-Type: text/html; charset=utf-8' ); 

You might also want to check on how to SET NAMES in mysql: query("SET NAMES utf8"); 您可能还需要检查如何在mysql中设置名称: query("SET NAMES utf8");

The basic thing to note is that when you are are working with unicode strings, you have to make sure that every aspect through which that data flows is unicode compliant so that it does not get lost anywhere in the pipeline. 基本要注意的是,当您使用unicode字符串时,必须确保数据流经的每个方面都符合unicode,以免在管道中的任何地方丢失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM