我已经在这里针对我的案例提供了许多答案,但它并没有起作用。
我在数据库中插入了一些阿拉伯语值。我将阿拉伯语值设为\u0645\u0628\u0627\u0631\u0627
。
My database collation is : UTF8_general_ci
Server charset: UTF-8 Unicode
Tables and columns collation are : UTF-8 Unicode
这是我的连接php文件:
<?php
$host="";
$user="";
$password="";
$db="";
$con= mysqli_connect($host,$user,$password,$db) or die("Unable to connect");
$sSQL= 'SET CHARACTER SET utf8';
mysqli_query($con,$sSQL);
if(mysqli_connect_error($con))
{
echo "Failed to connect to database ".mysqli_connect_error();
}
$sql="select id_livestream,name_match,time_match,name_league,name_stadium,name_team1,name_team2,image_team1,image_team2,live from Livestream,staduim,League WHERE Livestream.stadium=staduim.id_stadium and Livestream.league_type=League.id_league";
$result=mysqli_query($con,$sql);
if($result)
{
while($row=mysqli_fetch_array($result))
{
$flag[]=$row;
}
print(json_encode($flag));
}
mysqli_close($con);
?>
注意:阿拉伯语值已经成功插入到数据库中,但是当我检索数据时,我得到的数据就像\ u0645 \ u0628 \ u0627 \ u0631 \ u0627