Advertisement
Advertisement

新足迹

 找回密码
 注册
新足迹 › 门户 › IT与科技› 查看内容

(solved)Help with MySQL/PHP and GBK characters

2008-9-24 23:19| 发布者: 黑山老妖 | 查看: 630| 原文链接

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:
  1. <?php
  2. mysql_connect(localhost,$dbuser,$dbpw);
  3. # Set character_set_client and character_set_connection
  4. mysql_query("SET character_set_results=utf8", $con);
  5. mysql_query("SET character_set_client=utf8", $con);
  6. mysql_query("SET character_set_connection=utf8", $con);
  7.   
  8. @mysql_select_db($dbname) or die( "Unable to select database");


  9. $query="select column1, column2 from table limit 0, 10";
  10. $result=mysql_query($query);
  11. $num=mysql_numrows($result);

  12. mysql_close();

  13. echo "<b><center>Database Output - $num rows </center></b>

  14. ";

  15. if ($num > 0)
  16. {
  17.   $i=0;
  18.   echo "<table border="1">";
  19.   
  20.   while ($i < $num) {
  21.     $pid=mysql_result($result,$i,"PID");
  22.     $column1=mysql_result($result,$i,"column1");
  23.     $column2=mysql_result($result,$i,"column2");

  24.     echo "<tr><td>";
  25.     echo "<b>$column1</b>";
  26.     echo "</td><td>";
  27.     echo "$column2";
  28.     echo "</td></tr>";
  29.   
  30.   $i++;
  31.   }
  32. }
  33. ?>
复制代码
Only alphanumerics display okay. Chinese characters are just ???

Any help would be appreciated.

[ 本帖最后由 黑山老妖 于 2008-9-24 23:38 编辑 ]
Advertisement
Advertisement


Advertisement
Advertisement
返回顶部