Reputation: 21
i have a database that contains both chinese characters and english. when i queried the database to display them on my browser using php, all i get for the chinese characters are gibberish, none readable characters.
what i have tried: ini_set('mssql.charset', 'UTF-8') on the client side i made sure i included the meta tag specifying UTF-8.
am using mssql server language is php
any help will be great. thanks
Upvotes: 2
Views: 2059
Reputation: 1103
Try setting the character set within the PHP file after you've connected. Then run the query.
<?php
include('db_access.php');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
mysqli_set_charset($dbc, "utf8"); // Set the character set here!!
$query = "SELECT chinese FROM my_table";
while ($row = mysqli_fetch_array($query)) {
echo $row['chinese'].'<br />';
}
?>
PHP Manual: https://www.php.net/manual/zh/mysqli.set-charset.php
Upvotes: 0
Reputation: 561
I worked on a Chinese migration project last year and can point you at a few things to look at:
So a few things to check, try outputing some Chinese text on a sample .php file to confirm it is displaying as expected. Next, update your schema with the correct data types. Finally, point your test script at the DB to see if the data is displayed as expected.
Upvotes: 1