- 论坛徽章:
- 0
|
在winxp下,安装appserv2.5.8
在安装到mysql时,charset默认选utf8 unicode
通过PHPadmin配置mysql,生成一个新库test1,和表test,有两个段位:name和age
有两个记录:第一个记录是啊啊和30;第二个记录是aaa和20。
下面程序用IE打开,显示如下
Connected successfully
?? 30
aaa 30
为什么中文啊啊用??代替了。
不明白,请指教。
<?php
$mysql_server_name = "127.0.0.1";
$mysql_user = "root";
$mysql_password = "750722";
$mysql_database = "test1";
/* Connecting, selecting database */
$link = mysql_connect($mysql_server_name, $mysql_user, $mysql_password)
or die('Could not connect : ' . mysql_error($link));
echo 'Connected successfully';
mysql_select_db($mysql_database, $link)
or die('Could not select database');
/* Issue SQL query */
$query = 'SELECT * FROM test';
$result = mysql_query($query, $link) or die('Query failed : ' . mysql_error($link));
/* Printing results in HTML */
echo "<table border=\"1\">\n";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($row as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
/* Free result set */
mysql_free_result($result);
/* Close connection */
mysql_close($link);
?> |
|