Trying to do a select on MySQL table containing GBK characters and display it in PHP.
Every time I get ???? instead of chinese characters.
What do I need to do?
currently the php code look like this:- <?php
- mysql_connect(localhost,$dbuser,$dbpw);
- # Set character_set_client and character_set_connection
- mysql_query("SET character_set_results=utf8", $con);
- mysql_query("SET character_set_client=utf8", $con);
- mysql_query("SET character_set_connection=utf8", $con);
-
- @mysql_select_db($dbname) or die( "Unable to select database");
- $query="select column1, column2 from table limit 0, 10";
- $result=mysql_query($query);
- $num=mysql_numrows($result);
- mysql_close();
- echo "<b><center>Database Output - $num rows </center></b>
- ";
- if ($num > 0)
- {
- $i=0;
- echo "<table border="1">";
-
- while ($i < $num) {
- $pid=mysql_result($result,$i,"PID");
- $column1=mysql_result($result,$i,"column1");
- $column2=mysql_result($result,$i,"column2");
- echo "<tr><td>";
- echo "<b>$column1</b>";
- echo "</td><td>";
- echo "$column2";
- echo "</td></tr>";
-
- $i++;
- }
- }
- ?>
复制代码 Only alphanumerics display okay. Chinese characters are just ???
Any help would be appreciated.
[ 本帖最后由 黑山老妖 于 2008-9-24 23:38 编辑 ] |