Hello,
I have been tiring for a few days to get a picture removed from a file when data is deleted. It seems to work if I have the exact img hard coded but when I call it through $item_main_picture I receive a error telling me
###########
Warning: Division by zero in c:\phpdev5\www\public\mincom\item_delete_save.php on line 50
Warning: unlink() failed (Permission denied) in c:\phpdev5\www\public\mincom\item_delete_save.php on line 45
##########
Now all files are chomd 777
########## Below is the code.....I would appreciate any help here, thanks in advanced
<?php
$dbquery = "select * from itemmaster where autoid=\"$chk_1[0]\"";
$result = mysql_db_query($dbname,$dbquery); if(mysql_error()!=""){echo mysql_error();}
if($row = mysql_fetch_array($result))
{
$numrows = count($chk_1);
for($i=0;$i < $numrows;$i++)
{
$dbquery = "select categorytype from itemmaster where autoid=\"$chk_1[$i]\"";
$result = mysql_db_query($dbname,$dbquery); if(mysql_error()!=""){echo mysql_error();}
if($row = mysql_fetch_array($result))
{
$categorytype=$row[categorytype];
$dbquerycategory = "Update categorymaster set ";
$dbquerycategory = $dbquerycategory." items_in_category=items_in_category-1 ";
$dbquerycategory = $dbquerycategory." where (categorytype=\"$categorytype\")";
unlink(trim(items/mainpicture/$item_main_picture));
$resultcategory = mysql_db_query($dbname,$dbquerycategory);
if(mysql_error()!=""){echo mysql_error();}
}
$dbquery = "delete from itemmaster where autoid=\"$chk_1[$i]\"";
$result = mysql_db_query($dbname,$dbquery); if(mysql_error()!=""){echo mysql_error();}
}
echo "
<TABLE cellspacing=0 cellpadding=0 Align=center width='500' border=0>
<tr><td align=center height=25><font class=\"adminstd\"><b>STATUS</b></font></td></tr>
<tr><td align=center height=25><font class=\"adminstd\"><b>Requested Information has been Deleted.</b></font></td></tr>
</table>
";
}
else
{
ErrMessage("Access Denied");
}
?>
Thanks Jon