I've inserted some test echo statements here and there and I can't get the actual file name to be printed to the screen although the ID itself ($aa) seems to be printing to the screen.
When I run the code the filename is not printed although when I had the path printing it was printing. The script seems to run without any error messages so I'm not sure what's going wrong.
It seems my sql statement to select (file) from the table doesn't work. It seems to be empty.
Can someone offer some assistance? I'm sure there must be a way for me to delete the files based on the IDs that are being posted but what am I doing wrong? Currently there's no input filters but I will add that once I get this thing working.
Thanks!
Here's my Code:
Code: Select all
if($_POST['delete_photo'])
{
$images_delete = $_POST['delete_photo'];
if($images_delete!=Null)
{
foreach($images_delete as $aa)
{
$sql="select * from `images` where `id` = $aa";
$image_result=mysql_query($sql);
print mysql_error();
echo $aa;
echo "<br />";
echo "File name:";
echo $image_result['file'];
@unlink($thumbpath.$image_result["file"]);
@unlink($medpath.$image_result["file"]);
@unlink($lrgpath.$image_result["file"]);
$sql="delete from images where id = $aa AND user = $_SESSION[user_id]";
$result=mysql_query($sql);
print mysql_error();
}
}
}