在火狐下,PHP程序出错 在火狐下,PHP程序 在下订单时,更改了产品数量,但单价与数量相乘后,计算出来总价是错的.在IE下,是正常,怎么办 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 对头,php代码在服务器端执行,不存在浏览器不兼容的问题 猜测楼主使用了JS进行计算,PHP是在服务器端运行的,所以和浏览器没有关系。 服务器是美国的,的,在当前页面计算,代码如下:if($_REQUEST["act"]=="gx"){$pid=explode(',',$_REQUEST["allcheckboxs"]);for($i=0;$i<count($pid);$i++) { $bnum=$_REQUEST["carnumber".$pid[$i]]; $sql="update shop_cart set carnumber=$bnum where id=$pid[$i]"; $sql2="update shop_cart set total=carnumber*productprice where id=$pid[$i]"; $result=$db->query($sql,$conn); $result2=$db->query($sql2,$conn); } echo"<script>location.href='cart_list.php'</script>";} 请看2楼,PHP程序代码不关火狐、IE事情的,一个是服务端,一个是客户端,不存在兼容问题。只不过是PHP处理后的HTML语句和JS语句存在兼容问题。 以下本身全部代码,实在看不出来那里不兼容现在,我又测试了了,在火狐下,想改变购买产品的数量,我在输入框里面输入数字2,时,好像不执行if($_REQUEST["act"]=="gx")这个,输入框里面还是原先的1.<?@session_start();require('system/inc/db_conn.php');require('inc/pageft.php');$conn = $db->conn_open();if($_SESSION["login_status"]==""|| $_SESSION["login_status"]== false){ echo("<script>alert('Please Register or Login ');history.go(-1)</script>");}?><?if($_REQUEST["act"]=="del"){$id = $_REQUEST['id']; $sql = "delete from shop_cart where id='$id'"; $result = $db->query($sql,$conn); if($result){ echo("<script>location.href='cart_list.php'</script>"); }else{ echo("<script>alert('Delete Failure');location.href='cart_list.php'</script>"); }}if($_REQUEST["act"]=="gx"){$pid=explode(',',$_REQUEST["allcheckboxs"]);for($i=0;$i<count($pid);$i++) { $bnum=$_REQUEST["carnumber".$pid[$i]]; $sql="update shop_cart set carnumber=$bnum where id=$pid[$i]"; $sql2="update shop_cart set total=carnumber*productprice where id=$pid[$i]"; $result=$db->query($sql,$conn); $result2=$db->query($sql2,$conn); } echo"<script>location.href='cart_list.php'</script>";}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><LINK href="images/css.css" type=text/css rel=stylesheet><title>Shopping Cart</title><script language="javascript">function allcheckbox() { myform.allcheckboxs.value = ""; if ( !myform.checkbox1.length ) // 只有一个复选框,form3.checkbox1.length = undefined { if ( myform.checkbox1.checked ) myform.allcheckboxs.value = myform.checkbox1.value; } else { for ( i = 0 ; i < myform.checkbox1.length ; i++ ) { if ( myform.checkbox1(i).checked ) // 复选框中有选中的框 { myform.allcheckboxs.value = myform.checkbox1(i).value; for ( j = i + 1 ; j < myform.checkbox1.length ; j++ ) { if ( myform.checkbox1(j).checked ) { myform.allcheckboxs.value += ","; //用,做分割符 myform.allcheckboxs.value += myform.checkbox1(j).value; } } break; } } } return true; }</script></head><body><?require"top.php";?><table width="948" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="248" height="4"></td> <td width="3"></td> <td width="697"></td> </tr> <tr> <td rowspan="2" valign="top"> <? require("left.php");?> </td> <td> </td> <td rowspan="5" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="697" height="25" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/goods_head.gif"> <!--DWLayoutTable--> <tr> <td width="12" height="25"> </td> <td width="680" align="left" valign="middle" class="leftmenu">Shopping Cart</td> <td width="5"></td> </tr> </table></td> </tr> <tr><form action="?act=gx" method="post" name="myform" id="myform" onsubmit="allcheckbox()"> <td height="459" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="bian3"> <!--DWLayoutTable--> <tr> <td height="51" colspan="6" align="left" valign="top" style="border-bottom:2px #e3e3e1 dotted;"><img src="images/cartnavi-1.gif" width="599" height="49" /></td> </tr> <tr> <td height="25" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/2menubg.gif"> <!--DWLayoutTable--> <tr> <td width="131" height="25" align="center" valign="middle"><strong>Photo</strong></td> <td width="193" align="center" valign="middle">Product Name</td> <td width="126" align="center" valign="middle">Price($)</td> <td width="117" align="center" valign="middle">Amount</td> <td width="89" align="center" valign="middle">Subtotal</td> <td width="39"> </td> </tr> </table></td> </tr> <? $sql="select c.*,p.Class_photoa,p.sortid from shop_cart c,sq_class p where class_id=productid and userid =".$_SESSION['user_id']." and ordertype=1"; $result=$db->query($sql,$conn); $row=$db->num_rows($result); $tmoney=0; for ($i=0;$i<$row;$i++){ $rs=$db->fetch_array($result,MYSQL_BOTH); $tmoney=$tmoney+$rs["total"]; ?> <tr> <td width="130" height="160" valign="top"><img src="<?=$rs["Class_photoa"]?>" width="130" height="160" border="0" /></td> <td width="196" align="center" valign="middle"> <input name="checkbox1" type="checkbox" id="checkbox1" value="<?=$rs["id"]?>" checked="checked" style="display:none"/><?=$rs["productname"]?></td> <td width="123" align="center" valign="middle"><?=$rs["productprice"]?></td> <td width="116" align="center" valign="middle"><label> <input name="carnumber<?=$rs["id"]?>" type="text" class="textf" id="carnumber" value="<?=$rs["carnumber"]?>" size="4" maxlength="4"/> </label></td> <td width="87" align="center" valign="middle"><?=$rs["total"]?></td> <td width="43" align="center" valign="middle"><a href="?act=del&id=<?=$rs["id"]?>"><img src="images/b-delete.gif" width="39" height="22" border="0" /></a></td> </tr> <? } ?> <tr> <td height="127" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-top:2px #d2eafc solid;"> <!--DWLayoutTable--> <tr> <td width="285" height="50"> </td> <td width="58"> </td> <td width="352" align="right" valign="bottom" class="Price"><strong>Subtotal:<?=$tmoney?> $</strong></td> </tr> <tr> <td height="29"> </td> <td> </td> <td> </td> </tr> <tr> <td height="47"><!--DWLayoutEmptyCell--> </td> <td align="right" valign="middle"><!--DWLayoutEmptyCell--> </td> <td align="right" valign="middle"><a href="Products.php"><span class="productListing-data"> <input name="allcheckboxs" type="hidden" /> </span><img src="images/cart_continue.gif" width="103" height="23" border="0" /></a> <input type="image" src="images/cart_change.gif" name="Submit" value="提交" /> <a href="cart3.php"><img src="images/cart_next.gif" width="103" height="23" border="0" /></a></td> </tr> </table></td> </tr> <tr> <td height="69"> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table></td> </form> </tr> </table></td> </tr></table><? require"end.php";?> 你贴这个代码没用~你要贴输出的html 你的计算能不能不要放在那个slq语句中。?单独放到一个变量中。再update... 难道是用ajax,改变购物车里面的数量,你可以检查下ajax的浏览器兼容问题总结一下就是,在firefox不能改变产品数量 明显js有问题,跟php有何关系? php 程序还要看浏览器?第一次听。 这种一般是JS编写成了IE-only。在调试时,应该以Fx为出发点。 我也遇到这样的情况,很奇怪,在IE提交正常,FF就不行,在调试时,我用IE和FF来看print_r($_POST)的结果,IE下是完整的,FF有些缺失的,真的非常奇怪,不知道是哪里的问题 我的相反,在firefox下正常,在ie下就不正常到现在还不知道是什么原因............... 关于php socket通信的问题 求助 关于自动POST问题!急 两个类中方法的调用 请教pack函数。 最近怎么这么多自称菜鸟的? php 中文分词 php 中文分词类 php 中文分词详解 谁有用Zend编译过的文件可以可以我一个测试一下吗? 求助:我的phpMyAdmin怎么不好用了? PHP之GD库对图片中的汉字处理 我在申请的空间上传了phpmyadmin,配置完后,运行显示:CGI/PHP程序错误: 该脚本不允许执行!请问这怎么办? (祥情请进) PHP 怎么防盗链接打开页面? 急啊,大吓进来看看!在线等
if($_REQUEST["act"]=="gx")
{
$pid=explode(',',$_REQUEST["allcheckboxs"]);for($i=0;$i<count($pid);$i++)
{
$bnum=$_REQUEST["carnumber".$pid[$i]];
$sql="update shop_cart set carnumber=$bnum where id=$pid[$i]";
$sql2="update shop_cart set total=carnumber*productprice where id=$pid[$i]";
$result=$db->query($sql,$conn);
$result2=$db->query($sql2,$conn);
}
echo"<script>location.href='cart_list.php'</script>";
}
<?
@session_start();
require('system/inc/db_conn.php');
require('inc/pageft.php');
$conn = $db->conn_open();
if($_SESSION["login_status"]==""|| $_SESSION["login_status"]== false)
{
echo("<script>alert('Please Register or Login ');history.go(-1)</script>");
}
?>
<?
if($_REQUEST["act"]=="del")
{$id = $_REQUEST['id'];
$sql = "delete from shop_cart where id='$id'";
$result = $db->query($sql,$conn);
if($result){
echo("<script>location.href='cart_list.php'</script>");
}else{
echo("<script>alert('Delete Failure');location.href='cart_list.php'</script>");
}}if($_REQUEST["act"]=="gx")
{
$pid=explode(',',$_REQUEST["allcheckboxs"]);for($i=0;$i<count($pid);$i++)
{
$bnum=$_REQUEST["carnumber".$pid[$i]];
$sql="update shop_cart set carnumber=$bnum where id=$pid[$i]";
$sql2="update shop_cart set total=carnumber*productprice where id=$pid[$i]";
$result=$db->query($sql,$conn);
$result2=$db->query($sql2,$conn);
}
echo"<script>location.href='cart_list.php'</script>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<LINK href="images/css.css" type=text/css rel=stylesheet>
<title>Shopping Cart</title>
<script language="javascript">
function allcheckbox()
{
myform.allcheckboxs.value = "";
if ( !myform.checkbox1.length ) // 只有一个复选框,form3.checkbox1.length = undefined
{
if ( myform.checkbox1.checked )
myform.allcheckboxs.value = myform.checkbox1.value;
}
else
{
for ( i = 0 ; i < myform.checkbox1.length ; i++ )
{
if ( myform.checkbox1(i).checked ) // 复选框中有选中的框
{
myform.allcheckboxs.value = myform.checkbox1(i).value;
for ( j = i + 1 ; j < myform.checkbox1.length ; j++ )
{
if ( myform.checkbox1(j).checked )
{
myform.allcheckboxs.value += ","; //用,做分割符
myform.allcheckboxs.value += myform.checkbox1(j).value;
}
}
break;
}
}
} return true; }</script>
</head><body>
<?require"top.php";
?>
<table width="948" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="248" height="4"></td>
<td width="3"></td>
<td width="697"></td>
</tr>
<tr>
<td rowspan="2" valign="top">
<? require("left.php");?>
</td>
<td> </td>
<td rowspan="5" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="697" height="25" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/goods_head.gif">
<!--DWLayoutTable-->
<tr>
<td width="12" height="25"> </td>
<td width="680" align="left" valign="middle" class="leftmenu">Shopping Cart</td>
<td width="5"></td>
</tr>
</table></td>
</tr>
<tr><form action="?act=gx" method="post" name="myform" id="myform" onsubmit="allcheckbox()">
<td height="459" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="bian3">
<!--DWLayoutTable-->
<tr>
<td height="51" colspan="6" align="left" valign="top" style="border-bottom:2px #e3e3e1 dotted;"><img src="images/cartnavi-1.gif" width="599" height="49" /></td>
</tr> <tr>
<td height="25" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/2menubg.gif">
<!--DWLayoutTable-->
<tr>
<td width="131" height="25" align="center" valign="middle"><strong>Photo</strong></td>
<td width="193" align="center" valign="middle">Product Name</td>
<td width="126" align="center" valign="middle">Price($)</td>
<td width="117" align="center" valign="middle">Amount</td>
<td width="89" align="center" valign="middle">Subtotal</td>
<td width="39"> </td>
</tr>
</table></td>
</tr>
<?
$sql="select c.*,p.Class_photoa,p.sortid from shop_cart c,sq_class p where class_id=productid and userid =".$_SESSION['user_id']." and ordertype=1";
$result=$db->query($sql,$conn);
$row=$db->num_rows($result);
$tmoney=0;
for ($i=0;$i<$row;$i++){
$rs=$db->fetch_array($result,MYSQL_BOTH);
$tmoney=$tmoney+$rs["total"];
?>
<tr>
<td width="130" height="160" valign="top"><img src="<?=$rs["Class_photoa"]?>" width="130" height="160" border="0" /></td>
<td width="196" align="center" valign="middle"> <input name="checkbox1" type="checkbox" id="checkbox1" value="<?=$rs["id"]?>" checked="checked" style="display:none"/><?=$rs["productname"]?></td>
<td width="123" align="center" valign="middle"><?=$rs["productprice"]?></td>
<td width="116" align="center" valign="middle"><label>
<input name="carnumber<?=$rs["id"]?>" type="text" class="textf" id="carnumber" value="<?=$rs["carnumber"]?>" size="4" maxlength="4"/>
</label></td>
<td width="87" align="center" valign="middle"><?=$rs["total"]?></td>
<td width="43" align="center" valign="middle"><a href="?act=del&id=<?=$rs["id"]?>"><img src="images/b-delete.gif" width="39" height="22" border="0" /></a></td>
</tr>
<?
}
?>
<tr>
<td height="127" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-top:2px #d2eafc solid;">
<!--DWLayoutTable-->
<tr>
<td width="285" height="50"> </td>
<td width="58"> </td>
<td width="352" align="right" valign="bottom" class="Price"><strong>Subtotal:<?=$tmoney?>
$</strong></td>
</tr>
<tr>
<td height="29"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="47"><!--DWLayoutEmptyCell--> </td>
<td align="right" valign="middle"><!--DWLayoutEmptyCell--> </td>
<td align="right" valign="middle"><a href="Products.php"><span class="productListing-data">
<input name="allcheckboxs" type="hidden" />
</span><img src="images/cart_continue.gif" width="103" height="23" border="0" /></a>
<input type="image" src="images/cart_change.gif" name="Submit" value="提交" />
<a href="cart3.php"><img src="images/cart_next.gif" width="103" height="23" border="0" /></a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="69"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table></td>
</form>
</tr>
</table></td>
</tr>
</table>
<? require"end.php";?>
总结一下就是,在firefox不能改变产品数量
到现在还不知道是什么原因...............