<?php 
    session_start();
if(!isset($_SESSION['O_ID']))
     $_SESSION['O_ID']=date("YmdHis").substr(md5(uniqid(rand())),0,10);
?><!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" />
<title>无标题文档</title>
</head><body>
<form id="form1" name="form1" method="post" action="">
  <font size="+2">浏览商品|查看购物车|清空购物车  </font>
</form><form id="form2" name="form2" method="post" action="">
  <p><font size="+2">订单账号:</font><?php echo $_SESSION['O_ID']; ?>
    <input type="hidden" name="O_ID" id="O_ID" />
  </p>
  <table width="1065" height="160">
    <tr bgcolor="#000000">
      <th scope="col"><font color="#FFFFFF">商品编号</font></th>
      <th scope="col"><font color="#FFFFFF">商品名称</font></th>
      <th scope="col"><font color="#FFFFFF">商品单价</font></th>
      <th scope="col"><font color="#FFFFFF">订购数量</font></th>
      <th scope="col"><font color="#FFFFFF">小计</font></th>
    </tr>
    <?php foreach($_SESSION['Cart'] as $i => $val){ ?>
    <tr>
      <td><div align="center"><?php echo $_SESSION['Cart'][$i]; ?>
      </div></td>
       <td><div align="center"> 
         <p><?php echo $_SESSION['Name'][$i]; ?>
            <input name="D PName[]" type="hidden" value="<?php echo
   $_SESSION['Name'][$i];?>" />
         </p>
         <p>
           <label></label>
</p>
       </div></td>
        <td><div align="center">
          <p><?php echo $_SESSION['Price'][$i]; ?>
            <input name="D PPrice[] "type="hidden" value="<?php echo 
  $_SESSION['Price'][$i]; ?>" />
          </p>
          <p>&nbsp;    </p>
        </div></td>
      <td><div align="center">
        <p><?php echo $_SESSION['Quantity'][$i]; ?>
           <input name="D PQuantity[] " type="hidden" value="<?php echo 
 $_SESSION['Quantity'][$i]; ?>" />
        </p>
        <p>&nbsp;  </p>
      </div></td>
          <td><div align="center">
            <p><?php echo $_SESSION['itemTotal'][$i]; ?>
              <input name="D ItemTotal[]" type="hidden" value="<?php echo $_SESSION['itemTotal'][$i]; ?>" />
            </p>
            <p>&nbsp;      </p>
          </div></td>
    </tr>
    <tr>
      <td colspan="5"><div align="right">金额总计:<?php echo $_SESSION['Total']; ?></div></td>
    </tr>
    <tr>
      <td colspan="5"><label>
        <div align="right">
          <input type="submit" name="button" id="button" value="提交" />
        </div>
      </label></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</form>
</body>
</html>     (第91行)Parse error: syntax error, unexpected $end in C:\AppServ\www\Cart\img\checkout.php on line 91

解决方案 »

  1.  <?php foreach($_SESSION['Cart'] as $i => $val){ ?>  你这一句 少了最后的 }  <?php }?>
      

  2. 非常感谢啊
    不够把那个改错来之后还有一个小错误啊Warning: Invalid argument supplied for foreach() in C:\AppServ\www\Cart\img\checkout.php on line 35
    <?php 
        session_start();
    if(!isset($_SESSION['O_ID']))
         $_SESSION['O_ID']=date("YmdHis").substr(md5(uniqid(rand())),0,10);
    ?><!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" />
    <title>无标题文档</title>
    </head><body>
    <form id="form1" name="form1" method="post" action="">
      <font size="+2">浏览商品|查看购物车|清空购物车  </font>
    </form><form id="form2" name="form2" method="post" action="">
      <p><font size="+2">订单账号:</font><?php echo $_SESSION['O_ID']; ?>
        <input type="hidden" name="O_ID" id="O_ID" />
      </p>
      <table width="1065" height="160">
        <tr bgcolor="#000000">
          <th scope="col"><font color="#FFFFFF">商品编号</font></th>
          <th scope="col"><font color="#FFFFFF">商品名称</font></th>
          <th scope="col"><font color="#FFFFFF">商品单价</font></th>
          <th scope="col"><font color="#FFFFFF">订购数量</font></th>
          <th scope="col"><font color="#FFFFFF">小计</font></th>
        </tr>
        <?php foreach($_SESSION['Cart'] as $i => $val){ ?> } <?php }?>   这是第35行
        <tr>
          <td><div align="center"><?php echo $_SESSION['Cart'][$i]; ?>
          </div></td>
           <td><div align="center"> 
             <p><?php echo $_SESSION['Name'][$i]; ?>
                <input name="D PName[]" type="hidden" value="<?php echo
       $_SESSION['Name'][$i];?>" />
             </p>
             <p>
               <label></label>
    </p>
           </div></td>
            <td><div align="center">
              <p><?php echo $_SESSION['Price'][$i]; ?>
                <input name="D PPrice[] "type="hidden" value="<?php echo 
      $_SESSION['Price'][$i]; ?>" />
              </p>
              <p>&nbsp;    </p>
            </div></td>
          <td><div align="center">
            <p><?php echo $_SESSION['Quantity'][$i]; ?>
               <input name="D PQuantity[] " type="hidden" value="<?php echo 
     $_SESSION['Quantity'][$i]; ?>" />
            </p>
            <p>&nbsp;  </p>
          </div></td>
              <td><div align="center">
                <p><?php echo $_SESSION['itemTotal'][$i]; ?>
                  <input name="D ItemTotal[]" type="hidden" value="<?php echo $_SESSION['itemTotal'][$i]; ?>" />
                </p>
                <p>&nbsp;      </p>
              </div></td>
        </tr>
        <tr>
          <td colspan="5"><div align="right">金额总计:<?php echo $_SESSION['Total']; ?></div></td>
        </tr>
        <tr>
          <td colspan="5"><label>
            <div align="right">
              <input type="submit" name="button" id="button" value="提交" />
            </div>
          </label></td>
        </tr>
      </table>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
    </form>
    </body>
    </html>
      

  3. 你的$_SESSION['Cart'] 没有值吧
    话说你的帖子也该结了
      

  4. en好的,谢谢啊,你可以留个QQ联系下吗?我还有 几张网页想请你帮我看看啊
     全部搞好之后我可以付你一些钱啊,不过我还是个学生,钱也是非常有限的 就当谢谢你把
    你看行不行啊 
      

类似问题 »