一道php题如何来做?

来源:百度知道 编辑:UC知道 时间:2024/06/23 09:06:24
就是由PHP100网站提供的PHP视频第11-12集,为什么在我的电脑上无法实现。代码如下:
add.php-----
<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="发布留言"/>
</from>
<?php
include("conn.php");
if($_POST['submit']){
$sql="insert into message(id,user,title,content,lastdate)";
$sql=$sql."values('','$_post[user]','$_post[title]','$_post[content]',now[])";
mysql_query($sql);
echo "发表成功!";
}
?>
-----------------------------------------------
conn.php
<?php
$link=mysql_connect("localhost", "roo

我知道了~你的数据库插入时,id应该是自动增长的,不需要你手动插入的呀~而且一般ID为主键,怎么会要在数据库中插入呢~是不是?
所以,sql语句应为:
$sql = "insert into XX(name,...) values('$name',...)";

有什么问题?就是数据插入数据库,然后显示数据,程序大体没有问题

你建数据库了吗?

有没提示你什么错误信息?