首先
大家好,我是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>
------------------------------------------------------------------------------------