Hey, i am adding the ability for users to attach images to their posts on my forum.. Now... they can attach them fine, they attach them one at a time whilst writing the post and it gives a list of currently attached images. Now what i want to do is add the ability to unattach images.

The trouble is, i'm getting a 'page cannot be displayed' error when removing the image from an array. The address in the address bar is fine, no problem with that so i cant work out why i'm getting the error. ForumDiscardImage.php is the actual page that apparently can't be displayed. Anyway, heres the code that actually constructs the link:
Code:
if ($_GET['imagename']!="") { 
    $iname = $_GET['imagename']; 
    if (!isset($_SESSION['currentfiles'])) { 
        $_SESSION['currentfiles'] = $iname; 
        $attachedfiles = "<li>".$iname."<font size='-1'> - <a href='ForumDiscardImage.php?arraynumber=0&threadid=$threadid&sectionid=$sectid'>Discard Image</a></font></li>"; 
    }else{ 
        $sesh = $_SESSION['currentfiles']; 
        $exploded1 = explode(",", $sesh); 
        $inarray1 = count($exploded1)-1; 
            if ($exploded1[$inarray1]!=$iname) { 
                $sesh = $sesh.",".$iname; 
            } 
        $_SESSION['currentfiles'] = $sesh; 
        $exploded = explode(",", $sesh); 
        $inarray = count($exploded); 
            if ($inarray==6) { 
                $imglink = "ForumMaximum.php"; 
            }else{ 
                $imglink = "ForumPostImage.php?threadid=$threadid&sectionid=$sectid"; 
            } 
            for ($i=0; $i<count($exploded); $i++) { 
                $attachedfiles .= "<li>".$exploded[$i]."<font size='-1'> - <a href='ForumDiscardImage.php?arraynumber=$i&threadid=$threadid&sectionid=$sectid'>Discard Image</a></font></li>"; 
            } 
    } 
    unset($iname, $inarray, $exploded, $exploded1, $inarray1, $sesh, $i); 
    $attachmessage = "<b>Images currently attached:</b><br><br> <i>".$attachedfiles."</i><br>"; 
}
And heres the code that supposed to remove the image number from the array but its saying 'page cannot be displayed' instead:
Code:
$arraynumber = $_GET['arraynumber']; 
$tfid = $_GET['threadid']; 
$sfid = $_GET['sectionid']; 
$sesh = $_SESSION['currentfiles']; 
$exploded = explode(",", $sesh); 
$inarray = count($exploded); 
    if ($inarray==1) { 
        unset($_SESSION['currentfiles']); 
        unset($arraynumber, $sesh, $exploded, $inarray); 
        header("location: ForumNewReply.php?threadid=$tfid&sectionid=$sfid"); 
        exit(); 
    }else{ 
        for ($i=0; $i<$arraynumber; $i++) { 
            $sess1 .= $exploded[$i].","; 
        } 
        for ($i=$arraynumber+1; $i=$inarray-1; $i++) { 
            $sess2 .= $exploded[$i].","; 
        } 
        $finalsess = $sess1.$sess2; 
        $finalsesh = substr_replace($finalsess, "", -1); 
        $_SESSION['currentfiles'] = $finalsesh; 
        $exploded1 = explode(",", $finalsesh); 
        $inarray1 = count($exploded1)-1; 
        $lastitem = $exloded1[$inarray1]; 
        unset($arraynumber, $sesh, $exploded, $inarray, $sess1, $sess2, $finalsess, $finalsesh, $exploded1, $inarray1, $i); 
        header("location: ForumNewReply.php?threadid=$tfid&sectionid=$sfid&imagename=$lastitem"); 
        exit(); 
}
I've been studying this for hours and just cant work out why i'd be getting this error Can anyone PLEASE help?? Many thanks,

BIOSTALL