Hello all. In this code below, a string is exploded into an array, a specified key is unset, the related image is deleted, the array is imploded, finally, the database is updated.
Now, this works for EVERY id but 0.
Could someone explain why? 0 is the first key in the array, but I don't see why that would affect it.
$id = $_GET['id'];
$del_img = $_GET['del'];
$images = $myDb->dbFetch("SELECT img1 FROM ".$prefix."inventory WHERE uid='".$id."'");
$images = explode(",", $images[0]['img1']);
$image_del = $images[$del_img];
unset($images[$del_img]);
$images = implode(",", $images);
if(($myDb->dbQuery("UPDATE ".$prefix."inventory SET img1='".$images."' WHERE uid='".$id."'")) !== FALSE){
if(file_exists($tb_config[0]['dir']."imgs/".$image_del)){
@unlink($tb_config[0]['dir']."imgs/".$image_del);
@unlink($tb_config[0]['dir']."imgs/thumb_".$image_del);
echo 'Image removed.';
} else {
echo 'Could not find file to delete.';
}
} else {
echo 'Could not remove image from database.';
}
No errors, no ouput if id = 0, if id > 0 then everything works with output.
TIA.