Tuesday, May 22, 2018

php - How to retrieve Arabic data in MariaDB?

I have followed many answers here for my case and it doesn't work.



I have some Arabic values inserted in the database. I am getting Arabic values as \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


This is my connection php file :




$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);
?>



Note : Arabic values have been successfully inserted in the database but when I am retrieving the data I am getting it like \u0645\u0628\u0627\u0631\u0627

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...