Hi i got the folowing code to delete files and directories

if(isset($_POST['wissen']))
{
	
	$albid5= $_POST['album_id1'];
	$albnam = $_POST['albumbeschrijv'];
	
$error = "Es ist ein Problem mit der Datenverbindung aufgetreten,<br />probieren Sie es bitte später noch einmal<br />oder nehmen Sie Kontakt mit dem Webmaster auf.";
$connect = mysql_connect("localhost","bla","bla1") or die ($error);
mysql_select_db("bla") or die($error);
		
		
		$slides="slides";
		$thumbs="thumbs";
		$delete = mysql_query("DELETE FROM narr_weinachtfeier WHERE id='$albid5'")or die("Delete Error: ".mysql_error());
		echo mysql_error();
		$delete = mysql_query("DELETE FROM narr_fotos WHERE albumid='$albid5'")or die("Delete Error: ".mysql_error());
		echo mysql_error();
		
$dir1 = "$albnam/$slides/";
$dir2 = "$albnam/$thumbs/";
$dir3 = "$albnam/";
// Open a known directory, and proceed to read its contents  
		   
		   $mydir = opendir($dir1);
    while(false !== ($file = readdir($mydir))) {
        if($file != "." && $file != "..") {
            chmod($dir1.$file, 0777);
            if(is_dir($dir1.$file)) {
                chdir('.');
                destroy($dir1.$file.'/');
                rmdir($dir1.$file) or DIE("couldn't delete $dir$file<br />");
            }
            else
                unlink($dir1.$file) or DIE("couldn't delete $dir$file<br/>");				
				
line 1058                       rmdir($dir1);
				}    }	  
		   
		   $mydir2 = opendir($dir2);
    while(false !== ($file = readdir($mydir2))) {
        if($file != "." && $file != "..") {
            chmod($dir2.$file, 0777);
            if(is_dir($dir2.$file)) {
                chdir('.');
                destroy($dir2.$file.'/');
                rmdir($dir2.$file) or DIE("couldn't delete $dir$file<br />");
            }
            else
                unlink($dir2.$file) or DIE("couldn't delete $dir$file<br />");
line 1072				rmdir ($dir2);
line 1073				rmdir ($dir3);
				}   }   }

but it give me the folowing warnings:

Warning: rmdir(test 1/slides/) [function.rmdir]: Directory not empty in /var/www/php/login/album_Vereinsauftritte_gewahlt.php on line 1058

Warning: rmdir(test 1/thumbs/) [function.rmdir]: Directory not empty in /var/www/php/login/album_Vereinsauftritte_gewahlt.php on line 1072

Warning: rmdir(test 1/) [function.rmdir]: Directory not empty in /var/www/php/login/album_Vereinsauftritte_gewahlt.php on line 1073

when i look into the server i see the files and dir's are deleted.
But how ist it posible that these warnings are comming and what can i do about it ?

thanks in advice John

to suppress warning messages you can try to use @.

// line 46
@rmdir($dir2.$file) or DIE("couldn't delete $dir$file<br />");

Thanks for the repey but i rewrote the code into

if(isset($_POST['wissen']))
{
	
	$albid5= $_POST['album_id1'];
	$albnam = $_POST['albumbeschrijv'];
	
$error = "Es ist ein Problem mit der Datenverbindung aufgetreten,<br />probieren Sie es bitte später noch einmal<br />oder nehmen Sie Kontakt mit dem Webmaster auf.";
$connect = mysql_connect("localhost","bla bla","bla") or die ($error);
mysql_select_db("bla") or die($error);
		
		
		$slides="slides";
		$thumbs="thumbs";
		$delete = mysql_query("DELETE FROM narr_weinachtfeier WHERE id='$albid5'")or die("Delete Error: ".mysql_error());
		echo mysql_error();
		$delete = mysql_query("DELETE FROM narr_fotos WHERE albumid='$albid5'")or die("Delete Error: ".mysql_error());
		echo mysql_error();
		
$dir1 = "$albnam/$slides/";
$dir2 = "$albnam/$thumbs/";
$dir3 = "$albnam/";
// Open a known directory, and proceed to read its contents  		   
		   $mydir = opendir($dir1);    		
			foreach(glob($dir1.'*.*') as $file1){
			unlink($file1);
				}
				closedir($mydir );
				
				
				$mydir1 = opendir($dir2);
			foreach(glob($dir2.'*.*') as $file2){
				
			unlink($file2);
			
				}
			closedir($mydir1);

if (is_dir($dir3)) {				
$slides="slides";
		$thumbs="thumbs";		

$handle = opendir($dir3);
rmdir($dir3.$slides);
rmdir($dir3.$thumbs);
closedir($handle);
 rmdir($dir3);                
				} 


				}

and this works perfect whithout warnings and errors

Greets John

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.