I have a php script that connects to a MySQL database and returns some data in JSON, but the returned data that is in Greek appears as question marks.
I have checked the this question and didn't worked for me or I don't do it correct. What is wrong with it?
<?php
header('content-type: text/html; charset=UTF-8');
// Create connection
$con=mysqli_connect("localhost","db_user","db_pass","db_name");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if( function_exists('mysql_set_charset') ){
mysqli_set_charset('utf8', $con);
}else{
mysqli_query("SET NAMES 'utf8'", $con);
}
$sql = "SELECT * FROM Locations";
if ($result = mysqli_query($con, $sql))
{
$resultArray = array();
$tempArray = array();
while($row = $result->fetch_object())
{
$tempArray = $row;
array_push($resultArray, $tempArray);
}
echo json_encode($resultArray);
}
mysqli_close($con);
?>