dennismonsewicz Posted April 11, 2008 Share Posted April 11, 2008 Code: $query2 = mysql_query("SELECT * FROM uploads where id = " . $id . ""); $row = mysql_fetch_array($query2); $filename = $row['name']; $imgdir = "imageuploads/"; unlink($imgdir . $filename); For some reason the above code does not work. Any ideas? Link to comment https://forums.phpfreaks.com/topic/100695-solved-unlink-not-working/ Share on other sites More sharing options...
GingerRobot Posted April 11, 2008 Share Posted April 11, 2008 For starters, add error checking on the query: <?php $sql = "SELECT * FROM uploads where id = $id"; $result = mysql_query() or die(mysql_error().'<br />On the query:'.$sql); if(mysql_num_rows($result) == 1){ $row = mysql_fetch_assoc($result); $filename = $row['name']; $imgdir = "imageuploads/"; unlink($imgdir . $filename); }else{ echo 'ID does not exist!'; } ?> Link to comment https://forums.phpfreaks.com/topic/100695-solved-unlink-not-working/#findComment-514976 Share on other sites More sharing options...
dennismonsewicz Posted April 11, 2008 Author Share Posted April 11, 2008 ok did that and still it is not deleting it out of the dir Link to comment https://forums.phpfreaks.com/topic/100695-solved-unlink-not-working/#findComment-514984 Share on other sites More sharing options...
dennismonsewicz Posted April 11, 2008 Author Share Posted April 11, 2008 I fixed the problem Link to comment https://forums.phpfreaks.com/topic/100695-solved-unlink-not-working/#findComment-514993 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.