PHP Problem

Discussion in 'Software' started by Osiris990, Sep 19, 2005.

  1. Osiris990

    Osiris990 Private E-2

    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)

    PHP:
    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;
     
  2. Osiris990

    Osiris990 Private E-2

    Normally would never do this, but this is rather important, so... *bump*
     
  3. scouse

    scouse Corporal


MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds