0

I know this question has already been asked here, but there is still no solution for me ...

I have $http.post request to the server. It should return me the JSON file.

$http.post(getCountry, angular.toJson({country: true})).then(function (data) {
            $scope.countries = data.data;
            console.log( 'Success', $scope.countries);
        }, function (err) {
            console.log('err');
        });

The php code, which should send request to MySQL is as fallows:

$connection = mysqli_connect($server, $login, $password, $db) or die("Connection error" . mysqli_error($connection));

if ($country == 1) {
    $sql = "SELECT name_ru, id FROM net_country ORDER BY name_ru";
    $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));   
}

$emparray = array();
while($row =mysqli_fetch_assoc($result))
{
    $emparray[] = $row;
}
echo json_encode($emparray);

This one returns JSON with "?????" instead of the "name_ru" When I change "name_ru" to "name_en" - everything is ok.

I have no idea how to fix it. UTF-8 charset is everywhere

P.Shustenko
  • 93
  • 13
  • 2
    I have previously written [**an answer**](http://stackoverflow.com/questions/31897407/mysql-and-php-utf-8-with-cyrillic-characters/31899827#31899827) that contains a little checklist, that will cover *most* of the charset issues in a PHP/MySQL application. There's also a more in-depth topic, [UTF-8 All the Way Through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through). Most likely, you'll find a solution in either one or both of these topics. – Qirel May 07 '17 at 19:54
  • Execute `show create table name_ru` and see its encoding. – Michael May 07 '17 at 19:54
  • @Qirel Thank you very much. I have found the solution in your post! – P.Shustenko May 07 '17 at 20:14
  • Possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – Charlotte Dunois May 07 '17 at 21:27

0 Answers0