Unlinking Image 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
User avatar
maskme
Forum Newbie
Posts: 6
Joined: Sun Jul 28, 2002 9:27 am

Unlinking Image Problem

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply