填完留言板 数据库中没有提交的数据怎么回事??
文件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>

解决方案 »

  1.   

    mysql_query($sql) or die(mysql_error());     报什么错
      

  2.   

     $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()");
      

  3.   

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''地方',' 大锅饭',now()' at line 1
      

  4.   

    在初期最好这样写,方便调试:$sql="insert into ted (id,user,title,content,lastdate) values ('','$_POST[user]'),'$_POST[title]','$_POST[content]'," .
      "now()";
    mysql_query($sql);
    #改成
    $sql="insert into ted (id,user,title,content,lastdate) values ('','".$_POST['user']."'),'".$_POST['title']."'," .
    "'".$_POST['content']."',now()";
    $res = mysql_query($sql);
    if(!$res)
    die("SQL:{$sql}<br>Error:".mysql_error());
    if(mysql_affected_rows() > 0){
    #while($rows = mysql_fetch_array($res,MYSQL_ASSOC)){
            #
    #}
    }else{
    echo "操作失败,Error:".mysql_error();
    }