File Deletion script via SQL not working - help please.
Posted: Wed Nov 24, 2010 6:31 am
Code: Select all
$result = mysql_query ("SELECT photoprimary FROM products WHERE trash = 'yes'");
while ($row = mysql_fetch_object($result))
{
$photoprimary = "<br/>Primary photo found and deleted.";
$path = $_SERVER['DOCUMENT_ROOT'].'/images/productphotos/'.$row->photoprimary;
$pathsmall = $_SERVER['DOCUMENT_ROOT'].'/images/productphotos/small/'.$row->photoprimary;
$fh = fopen($path, 'w') or die("Sorry there is a problem");
$fhsmall = fopen($pathsmall, 'w') or die("Sorry there is a problem.");
fclose($fh);
fclose($fhsmall);
unlink($path);
unlink($pathsmall);
$primcomplete = "y";
}mysql_free_result($result);I get this error when running it:
The permissions of the folder and files are all set 777 properly.Warning: fopen(/usr/local/psa/home/vhosts/domain.co.uk/httpdocs/images/productphotos/) [function.fopen]: failed to open stream: Is a directory in /usr/local/psa/home/vhosts/domain.co.uk/httpdocs/includes/a_productstrash.inc on line 71
Sorry there is a problem