I have following php code, I try to remove record from SQL table and all associated image files from file system. I use glob() function with variable $list so get all image files start from $list and give output to unlink function but it doesn't work, I believe I do something wrong here:
<?
define('SITE',true);
include("../adm/conf.php");
$del=mysql_query("SELECT id FROM notes WHERE id = 26571");
$count=mysql_num_rows($del);
if(@$count){
while($q=mysql_fetch_assoc($del)){
$p_del=mysql_query("SELECT LEFT(logo,LOCATE('_',logo) - 1) imagefile FROM `notes` WHERE id_message = '".$q['id']."'");
if(@mysql_num_rows($p_del)){
while($list=mysql_fetch_assoc($p_del)){
$filename=glob($list ."*");
if(file_exists("../upload/notes/".$filename))unlink("../upload/notes/".$filename);
}
}
mysql_query("DELETE FROM notes WHERE id='".$q['id']."'");
}
}
?>
Thanks, S