sql 语句应该是一个字符串,你这个明显是语法错误~~~

解决方案 »

  1.   

    "$_POST[username]"这类属于字符类型的改为'".$_POST['username']."'
    这样试试:
    $sql = insert into `message (id,username,title,password,sex,content,lastdate) values('','".$_POST['username']."','".$_POST['title']."','".$_POST['password']."','".$_POST['sex']."','".$_POST['content']."',now());`
      

  2.   

    我帮你改正了,自己看看那里不一样吧
    <?php
    include("common.php");
    if($_POST["submit"])
    {
    echo $sql="insert into message (id,username,title,password,sex,content,lastdate) values ('', '$_POST[username]','$_POST[title]','$_POST[password]','$_POST[sex]','$_POST[content]',now())";
    }
    ?>
      

  3.   


    呵呵,严重的格式错误。用楼上的和我回答的都可以。
    <?php
    include("common.php");
    if($_POST["submit"])
    {
    echo $sql="insert into message (id,username,title,password,sex,content,lastdate) values (\"\",\"{$_POST[username]}\",\"{$_POST[title]}\",\"{$_POST[password]}\",\"{$_POST[sex]}\",\"{$_POST[content]}\",now())";
    }
    ?> 
      

  4.   

    还有,数组的索引需要引号括住。(根据http://topic.csdn.net/u/20090208/17/38d220f6-bdf7-41b3-866c-03615cc9ab3f.html3楼的提醒)最终代码:
    <?php
    include("common.php");
    if($_POST["submit"])
    {
    echo $sql="insert into message (id,username,title,password,sex,content,lastdate) values (\"\",\"".$_POST['username']."\",\"".$_POST['title']."\",\"".$_POST['password']."\",\"".$_POST['sex']."\",\"".$_POST['content']."\",now())";
    }
    ?>