Array warning message. How to put these file names into array

I queried image names out of database, now I’m trying to load them into a variable. How do I load them as individual file names instead of concatenated together? Thanks.

Array ( [0] => red.jpggreen.jpgblue.jpg )
Warning: unlink(upload_test/Array) [function.unlink]: No such file or directory in /home /public_html/ test.php on line 78

$filename[] = $row['image0']. $row['image1']. $row['image2'];
		print_r($filename);
		unlink( UPLOAD_DIR.$filename );

Thanks, but I still get the same warning.

Array ( [0] => red.jpg [1] => green.jpg [2] => blue.jpg )
Warning: unlink(upload_test/Array) [function.unlink]: No such file or directory in /home/public_html/test.php on line 80


define('UPLOAD_DIR', 'upload_test/');

$query = "SELECT image0, image1, image2 FROM table WHERE  status = '$status' ";
		if($result = $db->query( $query )){
			$row = $result->fetch_array();
		}		
		$filename[] = $row['image0'];
		$filename[] = $row['image1'];
		$filename[] = $row['image2'];
		
		print_r($filename);
		unlink( UPLOAD_DIR.$filename );

$filename[] = $row['image0'];
$filename[] = $row['image1'];
$filename[] = $row['image2'];

And if you can get more rows from the database, you might want to use a foreach loop, right now you only get the first row returned by the query.

I did not know this. Your direction worked.

Thank you.

Now I can go to sleep.

You can’t unlink an array of filenames just by putting the array in the unlink() function :smiley:
If you don’t need that array anywhere else, why don’t you just do:


        unlink( UPLOAD_DIR.$row['image0'] ); 
        unlink( UPLOAD_DIR.$row['image1'] ); 
        unlink( UPLOAD_DIR.$row['image2'] ); 

Thanks for your response. I get a slightly different error with your suggestion. I post more of my code. Any idea’s?

Array ( [0] => Array ( [0] => red.jpg [image0] => red.jpg [1] => green.jpg [image1] => green.jpg [2] => blue.jpg [image2] => blue.jpg ) )
Warning: unlink(upload_test/Array) [function.unlink]: No such file or directory in /home/public_html/test.php on line 78

The directory is their and so are the three files.

$query = "SELECT image0, image1, image2 FROM table WHERE  status = '$status' ";
        if($result = $db->query( $query )){
            $row = $result->fetch_array();
        }        
        $filename[] = $row;
        //$filename[] = $row['image0']. $row['image1']. $row['image2'];
        print_r($filename);
        unlink( UPLOAD_DIR.$filename );

Assuming that each record relates to one file, in the while loop which your probably using to get the rows from the result set try:

$filename[] = $row;

then use a foreach loop to process each in in turn