douliang2087 2013-11-25 07:20
浏览 37
已采纳

使用希伯来语时,PHP就像查询找不到任何结果

I hope its allowed and i am not bothering here every 5 minutes with new questions but i need help at this .

I have this code , i got it from my last question before :

          $string = $purifier->purify(@$_POST['string']); 

          $query = "SELECT * FROM users WHERE user_fname like '%".$string."%' OR user_lname like '%".$string."%' OR username like  '%".$string."%' OR useremail like '%".$string."%'";
          mysql_query("SET NAMES 'utf8'");
          $result2 = mysql_query($query);
          $num = mysql_num_rows($result2);

          if($num == 1)
          {
             // return foreach with all results similar to the word thet write on the input.
          }else
          {
             // return wrong . no reuslts found
          }

This way working perfect with English words , when i using Hebrew words its not find nothing .

I did die to $string ,and the word was perfecly writed in hebrew and on utf8 , all my database using utf8_general_ci , all my pages have meta with utf8 encoding , all my site working perfect with hebrew .

But here with this code when i try to search like somthing in Database with hebrew words always says not found , when i try in english its found , any idea ?

Thanks a lot.

  • 写回答

2条回答 默认 最新

  • dongyou2714 2013-11-25 07:31
    关注

    Your page, probably, isn't encoded in UTF-8.

    If it was, when you printed the message you shouldn't see the Hebrew characters (unless you set header('Content-type: text/html; charset=utf-8'); before

    (If the page is utf-8 encoded and you don't have this header, or other with charset=utf-8 - you would get black rhombus signs with question marks).

    If order to encode it in UTF-8 you can open it with Notapad++ and select:

    Encoding -> Encode in UTF-8 Without BOM

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 爬取1-112页所有帖子的标题但是12页后要登录后才能 我使用selenium模拟登录 账号密码输入后 会报错 不知道怎么弄了
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点