首页上一页 1 下一页尾页 1 条记录 1/1页
《PHP开发典型模块大全》第四章添加回复: 回复不了?
发表在PHP图书答疑
2009-06-23
是否精华
是
否
版块置顶:
是
否
在第04\12\review_chk.php下的代码可用吗?我总是添加(回复)不了。总弹出'有错误,请返回'这句去了。是不是SQL语句不行?请问哪儿错了?
<?php
session_start();
include_once 'conn/conn.php';
$id=$_POST['id'];
$cont = $_POST['reviewcont'];
$name = $_SESSION['name'];
if(empty($id) or empty($cont)){
// if (empty($cont)){
echo "<script>alert('回复为空,请返回');history.go(-1);</script>";
exit();
}
//$insertsql = "insert into tb_mess (content,review,author) values('".$cont."',".$id.",'".(empty($name)?'匿名':$name)."')";
$insertsql = "insert into tb_mess(content,review,author) values('".$cont."',".$id.",'".$name."')";
mysql_query($insertsql);
if(mysql_affected_rows() == 1){
echo "<script>alert('回复成功');location='index.php';</script>";
exit();
}else{
echo "<script>alert('有错误,请返回');history.go(-1);</script>";
exit();
}
?>
<?php
session_start();
include_once 'conn/conn.php';
$id=$_POST['id'];
$cont = $_POST['reviewcont'];
$name = $_SESSION['name'];
if(empty($id) or empty($cont)){
// if (empty($cont)){
echo "<script>alert('回复为空,请返回');history.go(-1);</script>";
exit();
}
//$insertsql = "insert into tb_mess (content,review,author) values('".$cont."',".$id.",'".(empty($name)?'匿名':$name)."')";
$insertsql = "insert into tb_mess(content,review,author) values('".$cont."',".$id.",'".$name."')";
mysql_query($insertsql);
if(mysql_affected_rows() == 1){
echo "<script>alert('回复成功');location='index.php';</script>";
exit();
}else{
echo "<script>alert('有错误,请返回');history.go(-1);</script>";
exit();
}
?>