日期:2014-05-17  浏览次数:20482 次

留言板连接数据库的问题
填完留言板 数据库中没有提交的数据怎么回事??


文件conn.php:
<?php
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("bbs", $conn);
mysql_query("set names 'GBK'"); 

?>

文件add.php:

<?php

 include("conn.php");
 if($_POST[submit]){
  $sql="insert into ted (id,user,title,content,lastdate) values ('','$_POST[user]'),'$_POST[title]','$_POST[content]'," .
  "now()";
mysql_query($sql);
  echo "发表成功!";
 }
?>
<br /><hr/>
  <form action="add.php" method="post">
  用户名:
  <input type="text" name="user" /><br/>
  标题:
  <input type="text" name="title" size="10" maxlength="40"/><br/>
  内容:
  <textarea name="content" >
  </textarea><br/>
<hr/>
  <input type="submit" name="submit" value="发布留言"/>
  </form>

------解决方案--------------------
mysql_query($sql) or die(mysql_error());

报什么错
------解决方案--------------------
起码SQL中的括号就有问题
------解决方案--------------------
$sql="insert into ted (id,user,title,content,lastdate) values ('','$_POST[user]'),'$_POST[title]','$_POST[content]'," .
"now()";
里面有一个),要把它写在后面
 $sql="insert into ted (id,user,title,content,lastdate) values ('','$_POST[user]','$_POST[title]','$_POST[content]'," .
"now()");