darkfreaks Posted February 4, 2008 Share Posted February 4, 2008 Warning: unlink(gallery/) [function.unlink]: Is a directory in /home/www/vampirecity.cx-music.com/admindelete.php on line 120 Could not delete file line 120: <?php unlink($link) or die ("Could not delete file"); ?> Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/ Share on other sites More sharing options...
revraz Posted February 4, 2008 Share Posted February 4, 2008 Looks like your variable is pointing to a directory name and not a file name? Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457939 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 thats the point it is. $link= "gallery/$pic"; and i dont know how to make it so it unlinks pic but looks for it in te gallery? Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457940 Share on other sites More sharing options...
revraz Posted February 4, 2008 Share Posted February 4, 2008 Is the gallery folder one level below your script? What does $link display when you echo it? Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457944 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 link displays site.com/gallery/42392.jpg which is fine and yes gallery is in a folder below the main script Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457948 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 how would i unlink it right ??? Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457972 Share on other sites More sharing options...
rhodesa Posted February 4, 2008 Share Posted February 4, 2008 And you put the echo immediately before the unlink? The only other thing I can think of is that you have extra characters at the beginning of $pic. Try doing a var_export($link) and a text/plain content-type: <?php header('Content-type: text/plain;'); //Just for debugging .... var_export($link); //unlink($link) or die ("Could not delete file"); ?> Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457979 Share on other sites More sharing options...
revraz Posted February 4, 2008 Share Posted February 4, 2008 I dont see why $link would contain site.com. It should just contain the path/filename according to your code (even if you change the name from your own domain to site.com). Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457982 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 it doesnt the filepath is gallery/$pic however i combined it into link. Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457983 Share on other sites More sharing options...
revraz Posted February 4, 2008 Share Posted February 4, 2008 And have you tried it without it? Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457986 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 yes with it it deletes one file at a time and errors with that error without it does nothing and still errors. code is: [code include ('config.php'); if($_POST['pics']) { include ('config.php'); $result=mysql_query("DELETE FROM vc_pics WHERE pic='$pic'"); $result=mysql_query("DELETE FROM vc_pcomments WHERE pic='$pic'"); $link= "gallery/$pic"; unlink($pic) or die ("Could not delete file"); Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457991 Share on other sites More sharing options...
rhodesa Posted February 4, 2008 Share Posted February 4, 2008 where is $pic being set? are you referring to $_POST['pic']? Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457992 Share on other sites More sharing options...
revraz Posted February 4, 2008 Share Posted February 4, 2008 Maybe you should use just unlink($link) and not add the site.com? Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457993 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 hmmmm maybe its something in the code its not deleting it period. <?php $strTitle = "Admin Activity"; define('QUADODO_IN_SYSTEM', true); include ('includes/header2.php'); include ('config.php'); if($_POST['bulletin']) { foreach($_POST as $id) { include ('config.php'); mysql_query("DELETE FROM vc_bulletin WHERE id='$id'"); echo "Bulletins deleted<br>"; $date = date('l M d, Y g:i A'); $query = "INSERT INTO `vc_adminactivity` (`username`,`action`,`id`,`date`) VALUES('{$username}','Bulletins','{$id}','{$date}')"; mysql_query($query) or die(mysql_error()); mysql_close(); }; }; include ('config.php'); if($_POST['comments']) { foreach($_POST as $id) { include ('config.php'); mysql_query("DELETE FROM vc_comments WHERE id='$id'"); echo "Your comment(s) have been deleted<br>"; $date = date('l M d, Y g:i A'); $query = "INSERT INTO `vc_adminactivity` (`username`,`action`,`id`,`date`) VALUES('{$username}','comments','{$id}','{$date}')"; mysql_query($query) or die(mysql_error()); mysql_close(); }; }; include ('config.php'); if($_POST['contest']) { foreach($_POST as $id) { include ('config.php'); mysql_query("DELETE FROM vc_contest WHERE id='$id'"); echo "Entries deleted<br>"; $date = date('l M d, Y g:i A'); $query = "INSERT INTO `vc_adminactivity` (`username`,`action`,`id`,`date`) VALUES('{$username}','contest','{$id}','{$date}')"; mysql_query($query) or die(mysql_error()); mysql_close(); }; }; include ('config.php'); if($_POST['journal']) { $result="DELETE FROM vc_journal WHERE id=$id"; $result2="DELETE FROM vc_jcomments WHERE jid=$id"; mysql_query($result)or die(mysql_error() . "<p>error: :<br>$result<p>"); mysql_query($result2)or die(mysql_error() . "<p>error: :<br>$result2<p>"); echo "Your journal(s) have been deleted<br>"; $date = date('l M d, Y g:i A'); $query2 = "INSERT INTO `vc_adminactivity` (`username`,`action`,`id`,`date`) VALUES('{$username}','journal','{$id}','{$date}')"; mysql_query($query2) or die(mysql_error()); mysql_close(); }; include ('config.php'); if($_POST['jcomments']) { foreach($_POST as $id) { mysql_query("DELETE FROM vc_jcomments WHERE id='$id'"); echo "Your comment(s) have been deleted<br>"; $date = date('l M d, Y g:i A'); $query = "INSERT INTO `vc_adminactivity` (`username`,`action`,`id`,`date`) VALUES('{$username}','Journal comment','{$id}','{$date}')"; mysql_query($query) or die(mysql_error()); mysql_close(); } }; include ('config.php'); if($_POST['pcomments']) { foreach($_POST as $id) { mysql_query("DELETE FROM vc_pcomments WHERE id='$id'"); echo "Your comment(s) have been deleted<br>"; $date = date('l M d, Y g:i A'); $query = "INSERT INTO `vc_adminactivity` (`username`,`action`,`id`,`date`) VALUES('{$username}','pic comment','{$id}','{$date}')"; mysql_query($query) or die(mysql_error()); mysql_close(); }; }; include ('config.php'); if($_POST['videos']) { foreach($_POST as $id) { include ('config.php'); mysql_query("DELETE FROM vc_vids WHERE id='$id'"); echo "Video deleted<br>"; $date = date('l M d, Y g:i A'); $query = "INSERT INTO `vc_adminactivity` (`username`,`action`,`id`,`date`) VALUES('{$username}','video','{$id}','{$date}')"; mysql_query($query) or die(mysql_error()); mysql_close(); }; }; include ('config.php'); if($_POST['pics']) { include ('config.php'); $result=mysql_query("DELETE FROM vc_pics WHERE pic='$pic'"); $result=mysql_query("DELETE FROM vc_pcomments WHERE pic='$pic'"); $link= "gallery/$pic"; unlink($link) ; $date = date('l M d, Y g:i A'); $query = "INSERT INTO `vc_adminactivity` (`username`,`action`,`id`,`date`) VALUES('{$username}','picture','{$pic}','{$date}')"; mysql_query($query) or die(mysql_error()); mysql_close(); }; include ('includes/footer.php'); ?> Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-457999 Share on other sites More sharing options...
rhodesa Posted February 4, 2008 Share Posted February 4, 2008 You have several other problems with this script too... First, you should just open the mysql connection once and close it once Also, serveral times you use the code: if($_POST['somekey']) { foreach($_POST as $id) { You are probably looking for $_POST['somekey'] in the foreach, not $_POST can you post the output of print_r($_POST); so we can get an idea of what the data being submitted looks like? Link to comment https://forums.phpfreaks.com/topic/89429-solved-unlink-minor-problem/#findComment-458046 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.