我编写的$sql="insert into content (content_id,sender_id,topic_id,contenttext,contenttime) " .
   "values ('','2',$topic,'$_POST[contenttext]',now())";
语句在PHP网页中运行显示插入正常,可是到数据库中查看却没有插进去,但是同样echo出来的语句复制到MYSQL中执行确可以添加,想知道是哪里出了问题,希望大家能够帮忙,谢谢。

解决方案 »

  1.   

    用tcpdump抓包看看发到数据的到底是什么
    /usr/sbin/tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | egrep -i 
      

  2.   

    不会使用,能不能说清楚点,我已经下载了一个TCPDUMP包,但是不知道该如何使用。我是一个菜鸟级别的初级学习者,麻烦你了~~~
      

  3.   

    是啊,可是如何更改啊。同样的语句用到其他页面和MYSQL中就好使。是不是我弄的太乱了。
    <?php
    $connection = mysql_connect("localhost","root","") or die("连接数据库失败");
    mysql_select_db('dgl1',$connection) or die("选择数据库失败");
    $topic=$_GET['topic'];
     if($_POST["submit"]){
     mysql_query('set names utf8') ;
      $sql="insert into content (content_id,sender_id,topic_id,contenttext,contenttime) " .
       "values ('','2',$topic,'$_POST[contenttext]',now())";
      echo "<script language=\"javascript\">alert('添加成功');history.go(-2)</script>";
       }
     echo "<form action=addcontent.php?topic=$topic method=post name=myform onsubmit=return CheckPost();>
      留言内容:<textarea name=contenttext  cols=60 rows=9></textarea><br/>
      <input type=submit name=submit value=发布留言>
      </form>";
    ?>
    <SCRIPT language=javascript>
    function CheckPost()
    {
    if (myform.contenttext.value=="")
    {
    alert("必须要填写留言内容");
    myform.contenttext.focus();
    return false;
    }
    }
    </SCRIPT>  
      

  4.   

    但是同样echo出来的语句是什么样? 另外确认一下你的PHP连接的是不是你查询的数据库?