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 自制电路图为何无法驱动ESP01S?
  • ¥15 前端加access数据库
  • ¥15 ARCGIS 多值提取到点 ERROR 999999
  • ¥15 mysql异常断电, [MY-011971] [InnoDB]
  • ¥15 uni.onBluetoothDeviceFound熄屏不运行
  • ¥35 关于shodan搜索网络摄像头的各种方法详解
  • ¥15 求PHDA糖尿病并发症数据集,有偿
  • ¥15 为什么AVL fire DVI 界面里面的response Editor project 中的Summary result 点不了
  • ¥20 中标麒麟系统V4.0,linux3.10.0的内核,3A4000处理器,如何安装英伟达或AMD的显卡驱动,
  • ¥20 求文心中文心理分析系统(TextMind)