get_results( $wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."xyz_em_attachment WHERE id= %d",$xyz_em_attachId) ) ; if(count($attachDetails)==0){ header("Location:".admin_url('admin.php?page=newsletter-manager-manage-campaigns')); exit(); }else{ $attachDetails = $attachDetails[0]; $existingAttachmentName = $attachDetails->name; $dir = realpath(dirname(__FILE__) . '/../../../')."/uploads/xyz_em/attachments/"; unlink ($dir.$existingAttachmentName); $wpdb->query( $wpdb->prepare( "DELETE FROM ".$wpdb->prefix."xyz_em_attachment WHERE id= %d",$xyz_em_attachId) ) ; header("Location:".admin_url('admin.php?page=newsletter-manager-manage-campaigns&action=edit_campaign&id='.$xyz_em_campId)); exit(); } ?>