插入语句为什么只有两个字段插入进去?tpid总是为0,在插入语句前能输出tpid的值的
if($_POST["submit"]=="提交" ){
$tpid=$_POST[tpid];
$content=$_POST[txt_content];
$datetime=date("Y-m-d H:i:s");
echo "$tpid";
$INS="Insert Into tb_comment (content,datetime,tpid) Values ('$content','$datetime','$tpid')";
$info=mysql_query($INS);
if($info){
echo "<script> alert('成功发表评论!');</script>";
echo "<script> window.location.href='$_SERVER[HTTP_REFERER]';</script>";
}
else{
echo "<script> alert('评论发表操作失败!');</script>";
echo "<script> history.go(-1);</script>";
}
}
if($_POST["submit"]=="提交" ){
$tpid=$_POST[tpid];
$content=$_POST[txt_content];
$datetime=date("Y-m-d H:i:s");
echo "$tpid";
$INS="Insert Into tb_comment (content,datetime,tpid) Values ('$content','$datetime','$tpid')";
$info=mysql_query($INS);
if($info){
echo "<script> alert('成功发表评论!');</script>";
echo "<script> window.location.href='$_SERVER[HTTP_REFERER]';</script>";
}
else{
echo "<script> alert('评论发表操作失败!');</script>";
echo "<script> history.go(-1);</script>";
}
}
解决方案 »
- 关于apache服务器启动虚拟主机服务的问题,求大神指点
- 一个php文件获得另一个php文件中的标签的值
- 求高手帮助解决,只差最后一步。Apache+php5.3.2+mssql2008+Driver2.2+Native10.0(此错误信息很困扰我,前面都很顺利)
- 咨询mysql数据发布过后的问题!
- php新手提问!紧急求救
- 想把php这条路走得深一点,请问有必要拿一个网络工程师的证吗?
- Php能调用c的接口函数吗?
- 请问如何将MYSQL数据库表中的数据以表格形式显示出来,且偶数行背景颜色加深?
- 弱弱的一个问题~~
- 这个Rss哪里错了,我没看懂啊,麻烦大家看看
- 网页如何从wordpress调用文章更新板块,专业人员请进
- jquery a标签 传值
在处理表单那一页传过来的id输出是: \\\'26\\\'
但是 我要根据图片的id来评论的数据表里找与它相对应的评论内容啊,这样图片的id是int型,而保存在评论里的图片id是char,这就找不到了呀,要怎么办???
$x="\'26\'";
$y= str_replace("\'","",$x);
echo $y;?>
<?php if($_GET['id']){
$id=$_GET['id'];
//echo"$id";
$query=mysql_query("select * from tb_tpsc where id='$id'",$conn);
$row=mysql_fetch_array($query);
echo "<img src='$row[tpmc]'>";//显示大图
//echo "$id";
echo "<a href=commentform.php?tpid='$id'>评论图片</a>";//ID已经GET形式传递,评论页可以$_GET['id']获取到图片ID
}
?></div></td>
</tr>
<tr>
<td> <?php
$query2=mysql_query("select * from tb_comment1 ",$conn);
$row2=mysql_fetch_array($query2); {
$x="$row1[id]";
$y= str_replace("\'","",$x);
echo $y;
}
?>
<?php $query1=mysql_query("select * from tb_comment1 where id='$y' order by datetime desc",$conn);
$row1=mysql_fetch_array($query1);
echo $row1[content];
?>
$id=$_GET['id'];
//echo"$id";
$query=mysql_query("select * from tb_tpsc where id='$id'",$conn);
$row=mysql_fetch_array($query);
echo "<img src='$row[tpmc]'>";//显示大图
//echo "$id";
echo "<a href=commentform.php?tpid='$id'>评论图片</a>";//ID已经GET形式传递,评论页可以$_GET['id']获取到图片ID
}
?>
</div></td>
</tr>
<tr>
<td>
/*----------------------上面不是显示大图了嘛*//*----------------------下面为所对应的图片评论*/
<?php $query1=mysql_query("select * from tb_comment1 where id='$row[id]' order by datetime desc",$conn);
$row1=mysql_fetch_array($query1);
echo $row1[content];
?>
这样不行吗?