Click to See Complete Forum and Search --> : delete file


kproc
02-06-2007, 08:23 PM
Hi below is code that I'm trying to get to delete a file from a folder with the name found ina mysql table. the below is not setting a value to image. when I echo it the value "array is returned

$delete_image = mysql_query($query_delete_image)or die("SQL Error: $query_delete_image<br>" . mysql_error());

$image = mysql_fetch_assoc($delete_image);

$fh = fopen('adImage\images\$image', 'w') or die("can't open file");
fclose($fh);

unlink($image);

NogDog
02-06-2007, 09:32 PM
The return value of mysql_fetch_assoc() is an array, with the element keys being the names of the columns retrieved by the query. So the actual name will be something like $image['column_name'] where 'column_name' is whatever the applicable column would be from your query.

NightShift58
02-06-2007, 09:46 PM
Also... why the fopen()/fclose()?

kproc
02-06-2007, 10:19 PM
thank you for the help, I should have noticed my error NogDog. Nightshipt I removed the open file.


thanks