在php100下载了一些PHP视频教程。
然后自己买一本PHP的书籍。
学习了半个多月不过现在遇到问题了
请大家帮一下我。
conn.php链接数据库无问题。
add.php插入数据无问题
list.php无法从数据库读取数据
源代码如下1.conn.php<?php
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("bbs", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;?>
2.add.php<?php
include("conn.php");//引入连接数据库文件
if ($_POST['submit']){//当用户按下发布留言
$sql="insert into message(id,user,title,content,lastdate)values('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
//将提交内容到MYSQL
mysql_query($sql);
echo "留言发表成功";
//$del="DELETE FROM `bbs`.`message` WHERE `message`.`id` = 13 LIMIT 1";
//mysql_query($del);}
?>
<html>
<head>
<title>欢迎来到我的留言板</title>
</head>
<body>
<form action="add.php" method="post">
用户:<input type="text" size"10" name="user"/><br/>
标题:<input type="text" name="title"/><br/>
内容:<textarea name="content"></textarea><br/>
<input type="submit" name="submit" value="发布留言"/>
</form>
</body>
</html>
3.list.php<?php
include ("conn.php");?><table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?php
$sql="select * form message";
$query=mysql_query($sql);
while ($row=mysql_fetch_array($query)){


?>
  <tr bgcolor="#eff3ff">
  <td>标题:<?=$row[title] ?> 用户:<?= $row[user] ?></td>
  </tr>
  <tr bgColor="#ffffff">
  <td>内容:<?= $row [content] ?>  </td>
  </tr>
 <?php
 } 
 ?>
</table>