0

This is my code

$sql = 'SELECT * from customer';
  $statement = $connection->prepare($sql);
  $statement->execute();
  if($statement->rowCount())
  {
    $row_all = $statement->fetchall(PDO::FETCH_ASSOC);

    echo json_encode($row_all);         
  }  
  elseif(!$statement->rowCount())
  {
    echo "no rows";
   }

it show "????".when retrieve from thai alphabet.where i have to fix code in the linecode? thank you so much

ManaRuT
  • 27
  • 3
  • 1
    [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – simon Dec 21 '16 at 07:54
  • By the way, to easily handle the output on the front-end / receiving end, you should also send back json in case no rows were found. – jeroen Dec 21 '16 at 07:57

3 Answers3

0

Try to add this code in the first line in your php file

header('Content-type: text/plain; charset=utf-8');
Nikolay K
  • 3,770
  • 3
  • 25
  • 37
0

Run the following queries before your query.

$connection->query("SET NAMES 'utf8'");
$connection->query('SET CHARACTER SET utf8');
Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
0

you can update your table column collation type to "utf8_general_ci" if you want to insert any Thai symbol on it

Amit Kumar Sahu
  • 495
  • 6
  • 15