PHP Run Time Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Osiris
Forum Newbie
Posts: 4
Joined: Sun Jun 12, 2005 2:38 pm
Location: Texas, USA

PHP Run Time Problem

Post by Osiris »

Ok, so on I site I'm currently working on, it has a shopping cart system that utilizes the session to hold what the user is ordering. Here is my problem: when I try and execute the code to remove a thing from the cart, it takes like a minute to load the page, and when it does, it's not the GUI that it should be, but instead a blank page with absolutely no HTML at all. When I press the "back" button, I see it has done what it should have, but I just don't know what's wrong. The code in question is below... Any help?

(oh, and please, don't comment on the poor formatting/optimization of the code unless it's the cause of my problem... Right now I'm working just to get it completed; not to make it look pretty)

Code: Select all

case 'remove':
            if($_GET['ext'] == "all") {
             foreach($_SESSION['sell_items'] as $keyy => $vall) {
              unset($_SESSION['sell_items'][$keyy]);
                }
                $output = '
<script language="javascript">

alert("All items successfully removed from shopping cart.");
location.href="checkout.php?do=viewcart";

</script>';
            } else {
             foreach($_SESSION['sell_items'] as $key => $val) {
                    if($key == $_POST['item_id']) {
                        $r_key = $key;
                        break;
                    } else {
                     $r_key = 'blahblah';
                    }
                }
            
             if($r_key === 'blahblah') {             
                    $output = '
<center>
There was an error in your request. Please try again. If problem persists, please contact an administrator.
</center>';
                } else {
              unset($_SESSION['sell_items'][$r_key]);
                    
                    $x = 0;
                 foreach($_SESSION['sell_items'] as $s_key => $s_val) {
                     $value = $s_val;
                     $ar_key = $s_key;
                  unset($_SESSION['sell_items'][$ar_key]);
                  $_SESSION['sell_items'][$x] = $value;
                        $x++;
                    }
                    
                    $output = '
<script language="javascript">

alert("Item successfully removed from shopping cart.");
location.href="checkout.php?do=viewcart";

</script>';
                }
            }
            break;
Post Reply