我通过本地主机在PHPMYADMIN中创建了SQL数据库 并尝试使用PHP显示存储在SQL中的数据 得到错误 这里是代码
<?php
$host = "localhost"; // Host name
$username = "sanoj"; // Mysql username
$password = "123456"; // Mysql password
$db_name = "sanoj"; // Database name
$tbl_name = "mobile";
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password") or die("cannot connect");
mysql_select_db("$db_name") or die("cannot select DB");
$sql = "SELECT * FROM $tbl_name ";
// OREDER BY id DESC is order result by descending
$result = mysql_query($sql);
?>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="10%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td>
<td width="10%" align="center" bgcolor="#E6E6E6"><strong>type</strong></td>
<td width="10%" align="center" bgcolor="#E6E6E6"><strong>title</strong></td>
<td width="10%" align="center" bgcolor="#E6E6E6"><strong>detail</strong></td>
<td width="10%" align="center" bgcolor="#E6E6E6"><strong>mobilebrand</strong></td>
<td width="10%" align="center" bgcolor="#E6E6E6"><strong>location</strong></td>
<td width="10%" align="center" bgcolor="#E6E6E6"><strong>email</strong></td>
<td width="10%" align="center" bgcolor="#E6E6E6"><strong>phone</strong></td>
<td width="10%" align="center" bgcolor="#E6E6E6"><strong>name</strong></td>
<td width="10%" align="center" bgcolor="#E6E6E6"><strong>youare</strong></td>
</tr>
<?php
// Start looping table row
while ($rows = mysql_fetch_array($result)) {
?>
<tr>
<td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
<td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['title']; ?></a><BR></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['brand']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['type']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['email']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['phone']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['name']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['youare']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['mobilebrand']; ?></td>
</tr>
<?php
// Exit looping and close connection
}
mysql_close();
?>
<tr><td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Create New Topic</strong> </a></td></tr>
</table>
这是确切的OUTPUT