Home  >  Article  >  Backend Development  >  文章id传不进去!解决方案

文章id传不进去!解决方案

WBOY
WBOYOriginal
2016-06-13 10:17:051461browse

文章id传不进去!!!
$id=$row['id'];,已经测试有这个值。。

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><div id="addComment" style="width:800px; height:350px; margin-left:0px;"><form action="addcommentProcess.php?id=%24id" 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代码如下
$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




------解决方案--------------------
当然是传不过去啦

$id=$_GET['id'];
得到的是 '$id'

因为你在表单页并没有传递 $id 的值


------解决方案--------------------
八成是$id没有值
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn