dtgv52982 2018-11-13 06:52
浏览 49
已采纳

从数据库中检索阿拉伯数据

I have a simple search using PHP and MySQL

it works perfectly for English text, but for Arabic text it will not retrieve any data without any Error

while executing the same MySQL query on Database "PhpMyAdmin" works perfectly

Result.PHP


<?php
if(!isset($_POST["search"])){$_POST["search"]="";}
echo $search=$_POST["search"];  
$servername = "localhost";
$username = "aramtryf_laravel";
$password = "Reha@2015";
$dbname = "aramtryf_laravel";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$sSQL= 'SET CHARACTER SET utf8'; 

mysqli_query($conn,$sSQL); 

$sql = "  SELECT * FROM oldorgs WHERE org_name like '%$search%'  ";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {



echo    "<tr>
      <th scope='row'>".$row["org_name"]."</th>
      <td>".$row["gov"]."</td>
      <td>".$row["sector"]."</td>
      <td>".$row["email"]."</td>

    </tr>";


    }
} 
$conn->close();
?> 
  • 写回答

4条回答 默认 最新

  • dongrang9300 2018-11-13 10:22
    关注

    instead of

    $sSQL= 'SET CHARACTER SET utf8'; 
    
    mysqli_query($conn,$sSQL); 
    

    try

    mysqli_set_charset($conn,"utf8");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 利用JD51设计温度报警系统
  • ¥15 快手联盟怎么快速的跑出建立模型
  • ¥15 关于腾讯云服务器中,PHP页面无法打开的问题
  • ¥60 如何把照片修复成原始拍摄图
  • ¥80 Exited too quickly (process log may have details)
  • ¥15 爬知乎登录之后内容加载不出来
  • ¥15 怎么用protues测量通频带
  • ¥15 zepelin使用sparkInterpreter 异常
  • ¥15 paho mqtt 接收不到消息
  • ¥15 函数r关于两个分量y,z方向上的图像,分开画r随y的图像,r随z的图像