$id=$row['id'];,已经测试有这个值。。
<div id="addComment" style="width:800px; height:350px; margin-left:0px;">
<form action="addcommentProcess.php?id=$id" method="post">
<input type="submit" value="发表评论" > 
<input type="text" name="user_comment">
<br/>
<textarea  name="article_comment" rows="50" cols="152" style="width: 500px; height: 295px"> 
</textarea>
</form>
</div>addcommentProcess.php代码如下
<?php
$id=$_GET['id'];
$article_comment=$_POST['article_comment'];
$conn=mysql_connect("localhost","root","5200");
if(!$conn){
die ("连接失败".mysql_error());
}
mysql_select_db("blog",$conn) or die(mysql_error());mysql_query("set names utf8");$sql="insert into comment (id,article_comment) value ('$id','$article_comment')";
//我自己在mysql里面输入insert into comment (id,article_comment) value ('8','aaa');可以插入内容。mysql_query("set names utf8");$res=mysql_query($sql) or die(mysql_error());
if($res){

header("location:index.php");
}
?>点击 发表评论的时候 显示错误:Incorrect integer value: '$id' for column 'id' at row 1

解决方案 »

  1.   

    $sql="insert into comment (id,article_comment) values ($id,'$article_comment')";
    去掉单引号试试。
      

  2.   

    <form action="addcommentProcess.php?id=$id" method="post">这行ACTION后面可以跟参数么?
    要不换成<form action="addcommentProcess.php" method="post"> 然后id=$id用隐藏表单参数提交
      

  3.   

    当然是传不过去啦

    $id=$_GET['id'];
    得到的是 '$id'因为你在表单页并没有传递 $id 的值
    <form action="addcommentProcess.php?id=$id" method="post">
      

  4.   


    在这块:
    $sql="insert into comment (id,article_comment) value ('$id','$article_comment')";
    应该是:
    $sql="insert into comment (id,article_comment)  values ('$id','$article_comment')";楼主的编辑器用代码高亮就能看出来了
      

  5.   

    $id肯定有值的,我在 第一个 页面 用  echo  $id得到值了,应该是action不能用?传
      

  6.   

    echo $sql 看数据有没对啊。数据库对吗
      

  7.   

    用你测试了下
    结果如下
    insert into comment (id,article_comment) values ('$id',' a ')Incorrect integer value: '$id' for column 'id' at row 1
    难道传进来的是$id?
      

  8.   

    我再用 
    echo  $id;页面显示$id=9   $id这个值没错啊,为什么传到addcommentProcess.php的值是"$id"而不是9?求解决
      

  9.   

    你在$sql上面输出echo $id,把values ('$id',' a ')中的$id的引号去掉
      

  10.   

    引号去掉后就这样了,还是不行!
    insert into comment (id,article_comment) values ($id,' a a ')Unknown column '$id' in 'field list'
      

  11.   

    你是怎么进入 addcommentProcess.php 页面的。你表单中并没有看到提交按钮。你如何提交的? 
      

  12.   

    好像是这样 <form action="addcommentProcess.php?id=<?php echo $id?>" method="post">还有用firefox的firebug测试下,看url的id有没有值另一个地方
    $sql="insert into comment (id,article_comment) values ($id,'$article_comment')";
      

  13.   

    汗,提交按钮在上面啊
    <input type="submit" value="发表评论" > 
      

  14.   

    sorry。。眼花了。 那你在 addcommentProcess.php 页面中 :
    $id=$_GET['id'];
    echo $id; //输出什么
      

  15.   

    终于解决了,这样就对了
    <?php
    echo <<< HTML<div id="addComment" style="width:800px; height:350px; margin-left:0px;">
    <form action="addcommentProcess.php?id=$id" method="post">
    <input type="submit"  value="发表评论">
    <input type="text" name="user_comment"><br/>
    <textarea  name="article_comment" rows="50" cols="152" style="width: 500px; height: 295px"> 
    </textarea>
    </form>
    </div>
    HTML;
    ?>必须要在<?php ?>$id才有效
    麻烦大家了
      

  16.   

    终于解决了,这样就对了
    <?php
    echo <<< HTML<div id="addComment" style="width:800px; height:350px; margin-left:0px;">
    <form action="addcommentProcess.php?id=$id" method="post">
    <input type="submit"  value="发表评论">
    <input type="text" name="user_comment"><br/>
    <textarea  name="article_comment" rows="50" cols="152" style="width: 500px; height: 295px"> 
    </textarea>
    </form>
    </div>
    HTML;
    ?>必须要在<?php ?>$id才有效
    麻烦大家了