Yeah, I get tripped up on whether to use isset($foo) or empty($foo) particularly when sending query vars from one page to another. My understanding is that the form will create the vars regardless whether they have values or not, therefore isset will always be true, and if these values are 0 then empty is also true.
Anyway, thanks to Weedpacket the following script seems to work. I've posted it to demonstarte a point, the objective of this code can be done more simply by reading the directory that the files are in and deleting them before removing the directory they're in. This code refers to multiple file uploads from a form and the clean yp of the db and file directory if there are any errors uncounted on the way.
==============================================
if ($error||$mime_error)
{
$del_files_sql = "select picture1, picture2, picture3, picture4
from story
where id = $story";
$result = mysql_query($del_files_sql);
if($result){
while ($pic = mysql_fetch_array($result, MYSQL_ASSOC)) {
//while(list($key, $value) = each($pic)){//for debug
//echo "key = ".$key." value = ".$value."<br>";
//}
//$i=0;
//while($i < (count($pic)-1)){
for($i=1; $i<(count($pic)+1); $i++){
echo "picture".$i." = ".$pic[picture.$i]."<br>";
if(is_null($pic[picture.$i])){
echo $pic[picture.$i]." is NULL <br>";
//$i++; //note only use $i++ here when using while loop
continue;
}else{
$del_file = unlink($pic[picture.$i]);
if ($del_file){
$status .= "<p>Deleted file ".$pic[picture.$i]." successfully</p>\n";
}else{
$status .= "<p>Can't delete file ".$pic[picture.$i].", please try again later</p>\n";
}
}
//$i++;
}
}#end while
$del_dir = rmdir($the_path."/".$story);
if ($del_dir){
$status .= "<p>Deleted directory ".$the_path."/".$story." successfully</p>\n";
}else{
$status .= "<p>Can't delete directory ".$the_path."/".$story.", please try again later</p>\n";
}
===========================================
BTW - Should I use continue 1, when nesting a for loop inside a while loop, how does this work , the manual suggests that this will skip the outer loop and jump to the end? (or beginning) of the nested loop.
Cheers
Synfield :o