从数据库掉不出数据..

cloufei 2003-10-19 07:02:06
<html>
<head>
<title>图书显示</title>
</head>
<body>
<p> </p>
<p align="center"><font size="7" color="#ff0000" face="华文行楷"><b>图书显示</b></font></p>
<p><font color="#ff00ff" size="5" face="楷体_gb2312"><b>  目前库存图书:</b></font></p>
<?php
$con=mysql_connect("localhost","root","1234");
mysql_select_db("tushu");
$query="select * from library";
$result=mysql_query("$query",$con);
$rownumber=mysql_num_rows($result);
echo"<cneter>";
echo"<table border='1'><td>";
echo"<tr>";
echo"<td align=center> id </td>"
" <td align=center> name </td>"
"<td align=center> author </td>"
"<td align=center> classname </td>"
"<td align=center> edtidate </td>"
"</tr>";
while ($r=mysql_fetch_array($result))
{
$name=$r["name"];
$author=$["author"];
$id=$r["id"];
$classname=$r["classname"];
$editdate=$r["editdate"];
echo"<tr>";
echo"<td align='left'><font size='2'>$name</font></td>";
echo"<td align='left'><font size='2'>$author</font></td>";
echo"<td align='left'><font size='2'>$id</font></td>";
echo"<td align='left'><font size='2'>$classname</font></td>";
echo"<td align='left'><font size='2'>$editdate</font></td>";
echo"</th>";
}
echo"</table>";
echo"</table>";
?>
<p>  
<font face="楷体_gb2312" size="5" color="#ff00ff"><b>
<a href="index.php">返回</a></b></font></p>
</body>
</html>
显示不出数据库的数据???
...全文
52 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
ustcfrank 2003-10-20
  • 打赏
  • 举报
回复
我的qq:19369866
cloufei 2003-10-19
  • 打赏
  • 举报
回复
我在dos下输入select * from library能显出数据.
cloudzm 2003-10-19
  • 打赏
  • 举报
回复
你用mysql客户端连一下数据库,输select * from library;看有没有输出。
cloufei 2003-10-19
  • 打赏
  • 举报
回复
楼上的,不行,看了问题出在数据库上了.
ustb 2003-10-19
  • 打赏
  • 举报
回复
试试下面的。
$con=mysql_connect("localhost","root","1234");
mysql_select_db("tushu");
$query="select * from tpl";
$result=mysql_query($query,$con);
$rownumber=mysql_num_rows($result);
echo "<center>";
echo "<table border='1'><tr>";
echo "<td align=center> id </td>
<td align=center> name </td>
<td align=center> author </td>
<td align=center> classname </td>
<td align=center> edtidate </td>
</tr>";
while ($r=mysql_fetch_array($result))
{
echo"<tr>";
echo"<td align='left'><font size='2'>".$r['name']."</font></td>";
echo"<td align='left'><font size='2'>".$r['author']."</font></td>";
echo"<td align='left'><font size='2'>".$r['id']."</font></td>";
echo"<td align='left'><font size='2'>".$r['classname']."</font></td>";
echo"<td align='left'><font size='2'>".$r['editdate']."</font></td>";
echo"</tr>";
}
echo"</table>";
ustcfrank 2003-10-19
  • 打赏
  • 举报
回复
可能你的数据库没建好,或数据库的用户名、密码不对
cloufei 2003-10-19
  • 打赏
  • 举报
回复
麻烦各位大哥试一下,急死了.....
cloufei 2003-10-19
  • 打赏
  • 举报
回复
不行,
ustcfrank 2003-10-19
  • 打赏
  • 举报
回复
$result=mysql_query("$query",$con);

改为

$result=mysql_query($query,$con);

试试
cloufei 2003-10-19
  • 打赏
  • 举报
回复
是不是必须装zend加速啊?
cloufei 2003-10-19
  • 打赏
  • 举报
回复
目前库存图书:

"; echo""; echo"
"; echo" id " " name " " author " " classname " " edtidate " "
"; while ($r=mysql_fetch_array($result)) { $name=$r["name"]; $author=$["author"]; $id=$r["id"]; $classname=$r["classname"]; $editdate=$r["editdate"]; echo" "; echo" $name "; echo" $author "; echo" $id "; echo" $classname "; echo" $editdate "; echo""; } echo"
"; echo""; ?>
返回

改成第一种显示
caaclxf 2003-10-19
  • 打赏
  • 举报
回复
先把这一句改成:
$result=mysql_query($query) or die(mysql_error());
然后把错误代码贴出来让大家看看

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧