Page 1 of 1

Unlinking Image Problem

Posted: Mon Aug 05, 2002 4:18 am
by maskme
Hi I''ve this problem

There is this form from where a user can delete his ads from the db. Now the the records get deleted but Im unable to unlink (delete) those images associated with the records. How do i chk whether the image from the array is associated with the record.

Below is the code dat is the input of the form

<input type=\"checkbox\" name=\"list[]\" value=\"<? echo $row[''fldbkid''] ?>\">
<input type=\"hidden\" name=\"img[]\" value=\"<? echo $row[\"fldbkimage\"] ?>\">

if ($page==\"delete\")
{
for ($j=0; $j < count($list); $j++)
{
unlink( $img[$j] );
$dquery = \"delete from items where id=$list[$j]\";
$dresult = mysql_query($dquery) or die(\"Query failed 1\");
}
header(\"Location: delete.php\");
}

Plz Help!
THanz

Posted: Mon Aug 05, 2002 4:34 am
by twigletmac
Not sure whether it was you or if something went a bit screwy but all those quotes shouldn't be escaped:

Code: Select all

<input type="checkbox" name="list&#1111;]" value="<?php echo $row&#1111;'fldbkid'] ?>"> 
<input type="hidden" name="img&#1111;]" value="<?php echo $row&#1111;"fldbkimage"] ?>"> 

<?php
if ($page == "delete") &#123; 
    for ($j=0; $j < count($list); $j++) &#123; 
        unlink( $img&#1111;$j] ); 
        $dquery = "delete from items where id=$list&#1111;$j]"; 
        $dresult = mysql_query($dquery) or die("Query failed 1");
    &#125; 
    header("Location: delete.php"); 
&#125; 
?>
Have you read the user comments on the man page for unlink() it seems like people using Windows (you don't say which OS you're using so this may not apply to you) have had mixed success in getting it to work.

Mac

Posted: Tue Aug 06, 2002 1:33 am
by twigletmac
Please bump your posts instead of starting new topics with the same question in. It makes it easier to keep track of answers.

Thank you.

** bump **

Mac