Jump to content

Recommended Posts

Hi,

I have difficulty to set up the code.

What I try to do is to unlink 2 images (same name) in different folder.

This is my delete.php

<?php

include "../dbconnect.php";
$delete="DELETE from product WHERE id='$id'";
$result=mysql_query($delete);

if($result)
{
header("location:index.php");
}
else
{
echo "Delete process failed";
    echo "<a href=index.php>Try again</a><br>";
    echo "<a href=logout.php>Logout</a><BR>";
}

?>

 

I've tried to add this code:

$image = "SELECT image FROM products WHERE id = '$id'";
unlink('images/$image);
unlink('images/thumbnail/$image);

 

But it doesn't work.

 

Could anybody help me?

 

Thanks,

ayok

But

Silly question, but are you getting the 'image' name before deleting the entry, e.g. why didn't you just show the new code? After that check permissions, (e.g. if you created the images you should be able to delete them!)

refs:

http://us3.php.net/manual/en/function.fstat.php, see 'mode'

http://us3.php.net/manual/en/function.chmod.php

All right,

I can now unlink the image files from the image folder in localhost. But when I test it on web server, i keep getting this error:

Warning: unlink() [function.unlink]: http does not allow unlinking in /home/mywebcom/HTML/products/admin/delete.php on line 8

I even set the permission to 777, but i still get this error. How can I solve this?

 

Thank you,

ayok

But it's kind of weird, because i made an upload script where I can put an original image, then create two smaller images in different folders, and then in the same script, I am able to unlink the original image from the folder. So how come I couldn't unlink those two smaller images?

 

thanks,

ayok

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.