Home > Backend Development > PHP Tutorial > 帮忙看看修改数据库数据代码是否有错~该如何处理

帮忙看看修改数据库数据代码是否有错~该如何处理

WBOY
Release: 2016-06-13 10:20:09
Original
975 people have browsed it

帮忙看看修改数据库数据代码是否有错~!!!!
include 'include.php';
$id=$_POST['sid'];
$recname=$_POST['Recname1'];?
$description=$_POST['Description1'];
$requirements=$_POST['Requirements1'];
//这四个数据都已经传过来没,现在的错误就是修改失败,感觉应该是数据库修改的语句有误,但是我查了好多资料,还是没有找到答案,希望各位大侠帮忙解决下

if ($requirements==""){
echo "<script>window.open('addment.php','I2_2');alert(\"请输入职业要求!!!\");</script>";
}else {
$query="update recruitment set Recname='$recname' description='$description' requirements='$requirements' where id='$id'";
echo $query;
$result=mysql_query($query);
if(mysql_affected_rows()>0){
echo "<script>window.open('modment.php','I2_2');alert(\"修改成功!!!\");</script>";
}else{
echo "<script>window.open('modment.php','I2_2');alert(\"修改失败!!!\");</script>";
}
}

?>

------解决方案--------------------
$query="update recruitment set Recname='$recname' ,description='$description', requirements='$requirements' where id='$id'";
------解决方案--------------------
$query="update recruitment set Recname='$recname',description='$description' ,requirements='$requirements' where id='$id'";
字段之间用逗号隔开
------解决方案--------------------
$result=mysql_query($query) or die(mysql_error());
看报神马错
------解决方案--------------------
将你的sql 输出 到phpmyadmin执行看看是否正常
------解决方案--------------------
1、字段间要用逗号分开,这是规则,不能讨价还价的
2、确认传入的数据中的特殊字符已经被转义了
------解决方案--------------------
字段间不用逗号隔开的我还是头一次见。没用过。
$query=" update recruitment set Recname='{$recname}' ,description='{$description}', requirements='{$requirements}' where id='{$id}' ";
你拿着输出的sql语句去数据库执行,看看会不会报错。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template