Home >Backend Development >PHP Tutorial >echo <script>问题

echo <script>问题

WBOY
WBOYOriginal
2016-06-23 14:11:171183browse


	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;


删除提示输出的是正常 ,就是新增输出的不正常 ,怎么把代码也显示出来了


回复讨论(解决方案)

用什么浏览器测试的

我觉得是你浏览器的问题,在我的IE9下测试正常

'$sku','$salesku','$asin','$fnsku','$diqu','$accout','$type'

全都加上mysql_real_escape_string();
如:mysql_real_escape_string($sku);

怀疑你的变量里有引号没有转义,导致mysql insert into失败,

IE8,chrome,firefox都是这样的,难道是我电脑的问题???我明天去公司试试

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
Previous article:求一个web短信平台接口Next article:新手求