I am engaged in mobile development with PHP affairs did not have. There is a script that mysql database converts to the JSon format, but the Cyrillic alphabet cannot be replaced with the Cyrillic alphabet simply by asking question marks, please help:

<?php $db_name="probnik"; $mysql_user="root"; $mysql_pass=""; $server_name="localhost"; $con=mysqli_connect($server_name,$mysql_user,$mysql_pass,$db_name); $Name=$_POST['Query']; $sql="SELECT * FROM exam WHERE Name LIKE '%$Name'"; $query=mysqli_query($con,$sql); if($query){ while($row=mysqli_fetch_array($query)) { $data[]=$row; } print(json_encode($data)); }else{ echo('Not Found'); } mysqli_close($con); ?> 

    1 answer 1

    Try to add after connecting to the database

     mysqli_set_charset($con, 'utf8'); 

    And save the php file itself in UTF-8 format.

    • in what part of the code add it? - elik
    • The author does not use mysql_ functions in his code! - Visman
    • @elik Try to add immediately after connecting to the database. - AlexOrtizzz
    • Warning: mysqli_set_charset () expects exactly 2 parameters, 1 given in E: \ wamp64 \ www \ example \ init.php on line 14 - elik
    • Notice: Undefined index: Query in E: \ wamp64 \ www \ example \ init.php on line 1 - elik