fopen() Problem
Posted: Mon Sep 20, 2010 3:06 pm
Folks.
This is driving me mad. I think it's a formatting error but I've been round in circles trying every combination I can think of. Basically, this section of my PHP interrogates a table in my dB and deletes all files listed under a particular code.
And this is the error I keep getting...
This is driving me mad. I think it's a formatting error but I've been round in circles trying every combination I can think of. Basically, this section of my PHP interrogates a table in my dB and deletes all files listed under a particular code.
Code: Select all
$query2 = "SELECT filename FROM photos WHERE code='$code'";
$result = mysql_query($query2)
or die (mysql_error());
// SET THE LOOP TO DELETE PHOTOGRAPHS
while($row = mysql_fetch_assoc($result))
{
$filename2 = $query2;
extract($row);
$myFile = "../photos/$filename2";
$fh = fopen($myfile,'w') or die ("Can't open file");
fclose($fh);
unlink($myFile);}What am I doing wrong?!Warning: fopen() [function.fopen]: Filename cannot be empty in /home/beautyby/public_html/admin/price.php on line 41
Can't open file