doushi6947 2015-05-23 19:05
浏览 342

PHP MYsql查询汉字

PHP MYsql Query Chinese Character

I did the following

My database was set to UTF-8

I also did the code

SET NAMES 'UTF8';
SET CHARACTER SET 'UTF8';

My sql was able draw the data out from my table using php mysql query select all rows, then display in a HTML page, the Chinese character nicely as Chinese words.

But when I try to do a select statement by i, below is the result

select * from account;

|       1 | �逵               |
|       2 | 宋江               |

The text will appear in this weird format above, so I did the following to draw the Individual record

SELECT role_id,UserId FROM accounts where UserName='宋宋';

However it did not get the result, although the Chinese character match.

The weird thing is if I select all rows, and display them out in a table, it looks perfectly like the chinese word that was key in.

But when I type the word in mysql itself or trying use mysql select statement by the chinese character, the statement yield 0 row which suppose to be 1 row.

TL:DR

How do I do a sql select statement where the input is in Chinese character, M y record in sql is not in the chinese format (although it display in Chinese word if i echo it weird encoding into a html table)

Thanks

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥15 stable diffusion
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条