引用 | 編輯
saladin919
2009-03-11 16:27 |
樓主
▼ |
||
x0
首先大家好,我是PHP新手? 因為我網站是架在某空間 然後那網站所提供的環境如下: localhost 伺服器版本: 4.1.21-standard-log 通訊協定版本: 10 伺服器: Localhost via UNIX socket 使用者: vhost10921@localhost MySQL 文字編碼: cp1252 West European (latin1) MySQL 連線校對: utf8_unioode_ci phpMyAdmin - 2.11.8.1 MySQL 客戶端版本: 4.1.21 己使用 PHP 擴充附件: mysql Language 中文繁體big5 上面while迴圈部分顯示出來的資料都是亂碼 我上網找資料大都說只要加mysql_query就可以解決亂碼 可是,不管我怎麼加就是沒辦法解決 囧 是還有哪邊我需要更改的嗎 囧? 複製程式 ---------------------sql.php---------------------------------- <? $db_host = "localhost"; $db_username = "名"; $db_password = "密碼"; $link = mysql_connect($db_host, $db_username, $db_password); mysql_query("SET NAMES 'utf8'",$link); mysql_query("SET CHARACTER_SET_database= utf8",$link); mysql_query("SET CHARACTER_SET_CLIENT= utf8",$link); mysql_query("SET CHARACTER_SET_RESULTS= utf8",$link); if(!$link) { echo "false"; }else{ echo "我ok"; } ?> ------------------------------------------------------------------------------ ------------------------------news2.php--------------------------------------- <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=big5" /> <title>news</title> </head> <body> <div align="center"> <table border="0" cellPadding="2" cellSpacing="1" width="100%"> <tr > <td width="57%" height="28" background="images/cellpic1.gif"> <div align="center"> 主題</div> </td> <td width="15%" height="28" background="images/cellpic1.gif"> <div align="center"> 瀏覽人數</div> </td> <td width="25%" height="28" background="images/cellpic1.gif"> <div align="center"> 加入日期</div> </td> </tr> </table> <marquee height=150 class="myscroll" direction="up" onmouseout="this.start();" onmouseover="this.stop();" scrollAmount="1" height="60" scrollDelay="90"> <? include ("sql.php"); $seldb = @mysql_select_db("DB"); if(!$seldb) { echo "FALSE"; }else{ echo "OK"; } $sql_query = "SELECT * FROM shopnews_table"; $result = mysql_query($sql_query); $total_records = mysql_num_rows($result); ?> <table border="0" cellPadding="2" cellSpacing="1" width="100%"> <? while($row_result=mysql_fetch_assoc($result)){ echo "<tr>"; echo "<td>".$row_result["suj"]."</td>"; echo "<td>".$row_result["point"]."</td>"; echo "<td>".$row_result["date"]."</td>"; echo "</tr>"; } ?> </table>123 </marquee> </div> </body> </html> ------------------------------------------------------------------------------------ x0
|
引用 | 編輯
ptskl
2009-03-11 18:12 |
1樓
▲ ▼ |
用phpmyadmin檢查看看
如果你的原始資料沒有亂碼 那麼試試看把 php文件用記事本開啟 存成utf8格式 再來檢查你網頁的語系是否為utf8 再來存取時使用mysql_query是正確的 x0 |
引用 | 編輯
saladin919
2009-03-12 09:44 |
2樓
▲ |
嗯嗯
我把sql.php那邊的utf8全改成big5就可以了 謝謝 x0 |