case 'add' : //新增
$sku=$_POST['sku_txt'];
$salesku=$_POST['salesku_txt'];
$fnsku=$_POST['fnsku_txt'];
$diqu=$_POST['diqu_txt'];
$asin=$_POST['asin'];
$accout=$_POST['account'];
$type=$_POST['type'];
$query = mysql_query("insert into `sku_rule` (`item_code`,`sku`,`asin`,`fnsku`,`delivery_areas`,`account`,`type`)values('$sku','$salesku','$asin','$fnsku','$diqu','$accout','$type')");
if (mysql_affected_rows($conn) != 1){
echo "<script> alert('添加失败!');location.href='sku_comparison.php';</script>";
} else {
echo "<script> alert('添加成功!');location.href='sku_comparison.php';</script>";
}
break;
case 'del' : //删除
$id=$_GET["delivery"];
$SQL = "delete from `sku_rule` where id in($id)";
$result = mysql_query($SQL);
if (mysql_affected_rows($conn) != 1){
echo "<script>alert('删除失败!');location.href='sku_comparison.php';</script>";
} else {
echo "<script>alert('删除成功!');location.href='sku_comparison.php';</script>";
}
break;
删除提示输出的是正常 ,就是新增输出的不正常 ,怎么把代码也显示出来了
------解决方案--------------------
'$sku','$salesku','$asin','$fnsku','$diqu','$accout','$type'
全都加上mysql_real_escape_string();
如:mysql_real_escape_string($sku);
怀疑你的变量里有引号没有转义,导致mysql insert into失败,