I've been having trouble figuring out what would cause a problem with a shopping cart not displaying it's contents when the link, entitled, 'My Cart' is clicked, and shows an empty cart.

But, when the checkout button is pressed from within the item being viewed, it displays the products within the cart.

The code looks fine, I just can't figure out what's wrong. Any help is appreciated. I'll include the confirmorder code....or mainly, the php code
PHP Code:
<? 
include('include/chkuserlogin.php');
include(
'include/getcartid.php');
require (
"include/connection.php");
require(
"include/pager.php");
$uname=$_SESSION['uname']; 
$a=$_SERVER['PHP_SELF'];
$asubstr$a0strpos$a"server_path.php" ) ) ; 
$a='http://'.$_SERVER['HTTP_HOST'].$a;
$site_url=$a;
 
$qry="select recID,username,email,name from user  where username='$uname'";
   
$r=mysql_query($qry) or die(mysql_error());                
while(
$rs=mysql_fetch_array($r))
{
        
$uname=$rs[1];
        
$email=$rs[2];        
           
$uid=$rs[0];
        
$name=$rs[3];
 } 
$qry="select paypalemail from adminlogin";
$r=mysql_query($qry) or die(mysql_error());                
while(
$rs=mysql_fetch_array($r))
{        
    
$pemail=$rs[0];                          

if(isset(
$_GET['did']))
{
 
$did=$_GET['did'];
 
$cart_id=$_GET['sesid'];
 
$qry="delete from cart where iid='$did' and uid='$uid' and sesid='$cart_id'";
  
mysql_query($qry);
 
$qry="delete from subcart where iid='$did' and uid='$uid' and sesid='$cart_id'";
  
mysql_query($qry); 
 echo 
"<script>window.location='confirmorder.php?sesid=$cart_id'</script>";
}    
if(isset(
$_GET['clr']))
{
 
 
$qry="delete from cart where uid='$uid' and sesid='$cart_id'";
 
mysql_query($qry);
 
$qry="delete from subcart where uid='$uid' and sesid='$cart_id'";
 
mysql_query($qry);
 echo 
"<script>window.location='confirmorder.php?sesid=$cart_id'</script>";

}    
if(isset(
$_POST['update'])) //UPDATE QUANTITY
{    

          
$cart_id=$_POST['cartid'];                                                                                           
          
$qry="select B.iid from cart B LEFT OUTER JOIN image A ON A.id= B.iid where sesid='$cart_id' and uid='$uid' ";                    
          
$r1=mysql_query($qry) or die(mysql_error());                
            while(
$rs1=mysql_fetch_array($r1))
          {
                
$iid=$rs1[0];                                                                              
                
$qry="select A.qty,B.pid from subcart A LEFT OUTER JOIN pricepack B on A.pid=B.pid where uid='$uid' and iid='$iid' and sesid='$cart_id'";                                                                
                
$r=mysql_query($qry) or die(mysql_error());                                    
                while(
$rs=mysql_fetch_array($r))
                {                                                                                                                    
                        
$qty=$rs['qty'];                                                                
                        
$pid=$rs['pid'];                                                                
                        
$qn=$pid.'a'.$uid.'a'.$iid;                                                                                                               
                        
$a=trim($_POST[$qn]);                                                        
                        if(
$a!=0)                        
                            
$qr="update subcart set qty='$a' where uid='$uid' and pid='$pid' and  iid='$iid' and sesid='$cart_id'";                                                                                                
                        else
                        {    

                            
$qr="delete from subcart where uid='$uid' and pid='$pid' and  iid='$iid' and sesid='$cart_id'";                                                                                                
                        }
                        
                            
mysql_query($qr);                                                    
                                                        
            
                }
        
         }                                                                                                    
            
                          
$qry1="select cid from subcart where uid='$uid' and iid='$iid' and sesid='$cart_id'";                    
                         
$rs=mysql_query($qry1);
                         if(@
mysql_num_rows($rs)== 0)
                         {
                              
$qry="delete from cart where uid='$uid' and sesid='$cart_id' and iid='$iid'";
                              
mysql_query($qry);
                          }    
}

?>
PHP Code:
<? $totp=0;$totitems=0;                                                       
                
$sesid=$_GET['sesid'];                
                 
$qry="select A.imgname,B.iid from cart B LEFT OUTER JOIN image A ON A.id= B.iid where sesid='$cart_id' and uid='$uid' ";                    
        
                
$r1=mysql_query($qry) or die(mysql_error());                
                  while(
$rs1=mysql_fetch_array($r1))
                {
                        
$img=$rs1[0];$iid=$rs1[1];    $l=strpos($img,'.');
                                                  
$im1=substr($img,0,$l);                                
                
?>
                                          <tr>
                                            <td align="left" valign="middle" bgcolor="#FFFFFF"><div align="center">
                                                <?  $img='admin/photos/'.$uname.'/'.$img
        echo 
"<img src=\"thumbnail.php?img=$img&w=75&h=75\" align=\"middle\" width=\"75\" height=\"75\"/>"?>
PHP Code:
<?
                                              
                        $qry
="select A.qty,B.size,B.price,B.pid from subcart A LEFT OUTER JOIN pricepack B on A.pid=B.pid where uid='$uid' and iid='$iid' and sesid='$cart_id'";                                                
                        
$subtotq=0;$subtotp=0;
                        
$r=mysql_query($qry) or die(mysql_error());                                    
                        while(
$rs=mysql_fetch_array($r))
                        {                                                            
                                
                                
$qty=$rs['qty'];
                                
$size=$rs['size'];
                                
$price=$rs['price'];
                                
$a=$size.' -$ '.sprintf("%.2f",$price);                                                
                                
$sprice=$price*$qty;                                    
                                
$subtotp=$subtotp+$sprice;                
                                
$subtotq=$subtotq+$qty;                                                                                                                                                                                                                          
                                  
$pid=$rs['pid'];                                
                                
$qn=$pid.'a'.$uid.'a'.$iid;    
                                
                            
?>
PHP Code:
   <?
                $qry1
="select * from cart where uid='$uid' and sesid='$cart_id'";                
                
$r=mysql_query($qry1);
                if(
mysql_num_rows($r)!=0)
                {     
                    
                    echo 
"<form id=\"form1\" name=\"upfrm\" method=\"post\" action=\"https://www.paypal.com/cgi-bin/webscr\"> 
                      <div align=\"center\">
                        <input type=\"hidden\" name=\"cmd\" value=\"_xclick\" />
                           <input type=\"hidden\" name=\"rm\" value=\"2\" />
                        <input type=\"hidden\" name=\"business\" value=\"$pemail\" />                                          
                        <input type=\"hidden\" name=\"cpp_header_image\" value=\"$site_url/bala/dnb/images/paylogo.jpg\">  
                        <input type='hidden' name='item_name' value=\"Images in DNB PHOTOGRAPHY\" />
                        <input type=\"hidden\" name=\"cart_id\" value=\"$cart_id\" />
                        <input type=\"hidden\" name=\"amount\" value=\"$totp\" />
                        <input type=\"hidden\" name=\"first_name\" value=\"$name\" />
                        <input type=\"hidden\" name=\"currency_code\" value=\"USD\" />
                        <input type=\"hidden\" name=\"uid\" value=\"$uid \" />
                       <input type=\"hidden\" name=\"bn\" value=\"PP-BuyNowBF\">
                        <input type='hidden' name='cn' value='DNB PHOTOGRAPHY  payment gateway!' />
                     <input type=\"hidden\" name=\"return\" value=\"$site_url/thanks.php?total=$totp&cart_order_id=$cart_id&uid=$uid\" />
                          <input type=\"hidden\" name=\"cancel_return\" value=\"$site_url/thanks.php?total=$totp&cart_order_id=$cart_id&uid=$uid&fail=fail\" />                  <input name=\"Submit\" type=\"submit\" class=\"colorbuttonsh\" value=\"Online Pay\" />                               
                        </div>
                    </form>"
;
                 }