darkfreaks Posted February 3, 2008 Share Posted February 3, 2008 ok so i got <?php mysql_query("DELETE FROM vc_pics WHERE pic='$pic'"); mysql_query("DELETE FROM vc_pcomments WHERE pic='$pic'"); $link = "gallery/$pic"; unlink($link); echo "Pics have been deleted<br>"; but i get Warning: unlink(/www/vampirecity.cx-music.com/gallery/Pictures_4816.jpg) [function.unlink]: No such file or directory how can i fix this? Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/ Share on other sites More sharing options...
trq Posted February 3, 2008 Share Posted February 3, 2008 Where is $pic defined? What is the output of... echo $link; ? Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457107 Share on other sites More sharing options...
CerealBH Posted February 3, 2008 Share Posted February 3, 2008 is the file already deleted? Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457109 Share on other sites More sharing options...
darkfreaks Posted February 3, 2008 Author Share Posted February 3, 2008 if($_POST['pics']) { foreach($_POST as $pic) { include ('config.php'); mysql_query("DELETE FROM vc_pics WHERE pic='$pic'"); mysql_query("DELETE FROM vc_pcomments WHERE pic='$pic'"); $link = "gallery/$pic"; unlink($link); echo "Pics have been deleted<br>"; Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457112 Share on other sites More sharing options...
trq Posted February 3, 2008 Share Posted February 3, 2008 And echoing $link produces? Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457114 Share on other sites More sharing options...
darkfreaks Posted February 3, 2008 Author Share Posted February 3, 2008 it echos the file of the picture but it seeems like it deletes and cant find the file because it does not exist? anyway to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457125 Share on other sites More sharing options...
darkfreaks Posted February 3, 2008 Author Share Posted February 3, 2008 here is my problem gallery/Pictures_350.jpg Warning: unlink(gallery/Pictures_350.jpg) [function.unlink]: No such file or directory in /home/www/vampirecity.cx-music.com/admindelete.php on line 120 Couldn't delete Pictures_350.jpggallery/Delete Pics Warning: unlink(gallery/Delete Pics) [function.unlink]: No such file or directory in /home/www/vampirecity.cx-music.com/admindelete.php on line 119 Warning: unlink(gallery/Delete Pics) [function.unlink]: No such file or directory in /home/www/vampirecity.cx-music.com/admindelete.php on line 120 Couldn't delete Delete Pics Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457146 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 ok this isnt properly done could someone show me an example on how to properly delete pics from a dir? Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457186 Share on other sites More sharing options...
mikefrederick Posted February 4, 2008 Share Posted February 4, 2008 depends upon your server. first, try replacing $link with an actual file address on your server. if you still get this error, i would try it on a different server, because unlink does not work for me on some sites and I get the same error you are getting even though the file actually exists. Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457190 Share on other sites More sharing options...
teng84 Posted February 4, 2008 Share Posted February 4, 2008 here's how to debug.. print your location or try to call that image using that location and try to figure out what is missing.. the error tells you that no such file or DIR so that means its either wrong dir or no image at all.. Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457191 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 well the image does not delete at ALL and tells me the dir doesnot exist. Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457195 Share on other sites More sharing options...
teng84 Posted February 4, 2008 Share Posted February 4, 2008 maybe give us the link for that image i direct link to that image so we can browse it from our browsers and your pages that deletes the image Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457201 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 they have it so it is $link="gallery/$pic"; unlink($link); but this throws the does not exist error Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457203 Share on other sites More sharing options...
mikefrederick Posted February 4, 2008 Share Posted February 4, 2008 i would really try it on another server, i have had that problem with unlink before and literally have copied the files to another server and it worked. don't get it. Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457204 Share on other sites More sharing options...
teng84 Posted February 4, 2008 Share Posted February 4, 2008 the link of that image? the link of that file? from there we can see if you're calling the right DIR Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457207 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 http://vampirecity.cx-music.com/gallery/aiz.jpg just an example Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457209 Share on other sites More sharing options...
teng84 Posted February 4, 2008 Share Posted February 4, 2008 echo '<img src="gallery/aiz.jpg" />'; unlink('gallery/aiz.jpg'); echo '<img src="gallery/aiz.jpg" />'; try and tell me the result? Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457212 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 the problem is is it is unlinking one file at a time and deleting it then saying it not exist? Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457216 Share on other sites More sharing options...
teng84 Posted February 4, 2008 Share Posted February 4, 2008 wow.. so the error lies on your dynamic image name $link = "gallery/$pic"; $pic is not containing the right value.. like what you said it ulink once that correct and it wont unlink twice because data has been deleted Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457222 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 how do i correct that Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457223 Share on other sites More sharing options...
teng84 Posted February 4, 2008 Share Posted February 4, 2008 see this if($_POST['pics']) { foreach($_POST as $pic) { you're looping into your post data does it mean your post data only contain values of your images what about your other post data it will also be inclided in your loop so even if you unlink some image at the end you get error.. if you have other post other than $_POST['pics'] good sample is your POST submit that is part of your post Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457225 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 so do i need ot change POST to something else im confuse? ??? Quote Link to comment https://forums.phpfreaks.com/topic/89271-solved-unlink-problem/#findComment-457227 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.