2012-04-16 2 views
0

에서 여러 이미지를 삭제 내 PHP 스크립트는 여러 이미지를 삭제하지 않습니다, 그냥 엄지 손톱 이미지를 삭제 한 다음 디렉토리에 두 번째 나뭇잎.PHP는 디렉토리

if($_POST['pic_id']){ 

    $pic_id = $_POST['pic_id']; 
    $pic_id = mysql_escape_String($pic_id); 

    # Select photo details from database 
    $query = mysql_query("SELECT * FROM gallery WHERE id='$pic_id'"); 
    $queryCount = mysql_num_rows($query); 

    if($queryCount>0){ 

    #Get the fields 
    while($row = mysql_fetch_array($query)){   
    $image= $row["image"]; 
    $thumbnail = $row["thumbnail"]; 

    } 

    # Unlink thumb source 
    //Delete the thumbnail photo from directory 
    $pic1 = ("$image"); 
    if (file_exists($pic1)) { 
    unlink($pic1); 
    } 
    # Unlink resize source 
    //Delete the big photo from directory 
    $pic2 = ("$thumbnail"); 
    if (file_exists($pic2)) { 
    unlink($pic2); 
    } 


    # Delete the row from the database 
    $sqlTable2 = mysql_query("DELETE FROM gallery WHERE id='$pic_id'"); 

    } else { 

     exit(); 
    } 

} 

일하기 위해 노력 해왔다. 당신은 당신의 while 루프 내에서 삭제 코드를 포장 할 필요가

+2

$ 행 [ "이미지"] == $ 이미지 == 세 가지 변수 $의 PIC1 모두 같은, 아니 필요 –

+0

무엇 '$ image'와'$ thumbnail'에 있나요? – mamadrood

답변

0

...

while($row = mysql_fetch_array($query)){   
    $image= $row["image"]; 
    $thumbnail = $row["thumbnail"]; 

    # Unlink thumb source 
    //Delete the thumbnail photo from directory 
    $pic1 = ("$image"); 
    if (file_exists($pic1)) { 
     unlink($pic1); 
    } 

    # Unlink resize source 
    //Delete the big photo from directory 
    $pic2 = ("$thumbnail"); 
    if (file_exists($pic2)) { 
     unlink($pic2); 
    } 
} 
+0

고마워요 Cilliosis 이제 작동합니다 – Raphael1