1

I'm helping for my school website,and then i try to display some data form the database,the image source and link is work just fine,but when try to display some chines string,is became ?????,my PHP document is already using UTF-8 and same as SQL utf8_unicode_ci,but is still showing some ?????

Showing content code:

header('Content-Type: text/html; charset=UTF-8');
$getNews = mysql_query("SELECT * FROM news");
while ($rows = mysql_fetch_array($getNews)) {
$img = $rows['img'];
$title = $rows['title'];
$link = $rows['link'];
echo '<div class="showNewsBox">';
  echo '<div class="showNews">';
   echo "<a href='$link' target='_blank'>";
    echo "<img src='$img' class='newsImage'>";
    echo "<h3 class='newsTitle'>" . $title . "</h3>";
   echo "</a>";
 echo "</div>";
}

PHP UTF-8 code

<meta charset="utf-8">
Felix Fong
  • 969
  • 1
  • 8
  • 21

2 Answers2

0

I think most voted answer of this question below will solve your problem: Can't insert Chinese character into MySQL

In short: set charset as UTF-8 when reading and writing to DB

mysql_query("SET character_set_client=utf8", $dbLink); 
mysql_query("SET character_set_connection=utf8", $dbLink);
Community
  • 1
  • 1
0

Just go to your database table structure and set collation utf8_unicode_ci for column which you want to display in chines!

Lokesh Jain
  • 579
  • 6
  • 19