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