<?php 
     session_register("total");
     if($_GET[qk]=="yes")
     {
     $_SESSION['idStr']="";
     $_SESSION['numStr']="";  
     }
      $arraygwc=explode("@",$_SESSION['idStr']);
      $s=0;
      for($i=0;$i<count($arraygwc);$i++)
      {
          $s+=intval($arraygwc[$i]);
      }
     if($s==0 )
       {
       echo "<tr>";
   echo" <td height='25' colspan='6' bgcolor='#FFFFFF' align='center'>您的购物车为空!</td>";
   echo"</tr>";
    }
     else
      {  
   ?>
这个我用来清空购物车和判断是否为空的 为啥就不执行 把这段去了 就能执行到else后面的内容

解决方案 »

  1.   

    没有看到 session_start();
      

  2.   

    <?php session_start();
     if($_SESSION['unc']=="")
      {
        echo "<script>alert('请先登录,后购物!');history.back();</script>";
     exit;
      }   
    ?>
    <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <form name="form1" method="post" action="gouwu1.php">
              <tr>
     <td height="25" bgcolor="#555555"><div align="center" style="color: #FFFFFF"><?php echo $_SESSION['unc'];?>的购物车</div></td>
              </tr>
              <tr>
     <td  bgcolor="#555555"><table width="500" border="0" align="center" cellpadding="0" cellspacing="1">这个我加在上面了 这里面也要加么