david212 Posted April 4, 2009 Share Posted April 4, 2009 Hello i have written this code, so i upload my pictures to mysql database, and then i want to delete them. I've used function unlink to delete them from the folder, but when i delete the file from folder the name of this file remains in mysql db. How can i delete from folder and mysql my uploaded images?? if(isset($_POST["del"])){ $ss = sizeof($_POST["d2"]); for($i=0;$i<$ss;$i++){ $a2 = "DELETE FROM upimgs WHERE id =\"".$_FILES["fl2"]["name"]."\""; mysql_query($a2); unlink("../upl_imgs/".$_POST["d2"][$i]); } } then i tried to delete manuallu, for example: $a2 = "DELETE FROM imgs WHERE id ='12'"; and this one works fine but i need to delete the same file im deleting from folder using unlink("../upl_imgs/".$_POST["d2"][$i]); Thanx Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted April 4, 2009 Share Posted April 4, 2009 you're asking it to delete where id=filename I'm pretty sure that won't work. Also I would quote it differently. try this $a2 = "DELETE FROM upimgs WHERE yourfilenamefield ='".$_FILES['fl2']['name']."'"; mysql_query($a2); unlink("../upl_imgs/".$_POST["d2"][$i]); Quote Link to comment 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.