0

I have saved my data on MYSQL database using "utf8_general_ci". I wrote it on Bangla font. But when I am trying to show data using php it is showing "????..." instead of showing the charecters.

<?php

$con = mysqli_connect("localhost","appsaadr_edu","pass","appsaadr_edu");

$result = mysqli_query($con,"SELECT * FROM lnews ORDER BY id DESC");

echo "{\"news\":";
$arr = array();

while($rows = mysqli_fetch_array($result)){
    $test['id'] = $rows['id'];
    $test['title'] = $rows['title'];
    $test['text'] = $rows['text'];
    $test['time'] = $rows['time'];

    array_push($arr,$test);

}

echo json_encode($arr);
echo "}";
?>

What to do now?

Sudarshan
  • 938
  • 14
  • 27

1 Answers1

0
  1. Make sure the file is encoded in UTF-8 without BOM
  2. Add : mysqli_set_charset($con,"utf8"); between the lines 3 and 5
  3. Put all the $test['XXX'] like this utf8_encode($test['XXX'])
  4. Make sure to add the data into the database also through utf8_encode before