Buon pomeriggio.
Ho scaricato un pacchetto per l'upload delle immagini
Poi avuto l'esigenza di dover eseguire SELECT,INSERT e DELETE, sulla tb_loghi.
Ed ho scaricato questo script:
Codice PHP:
$options = array('delete_type' => 'POST',    'db_host' => '',    'db_user' => 'user1234',    'db_pass' => 'user1234',    'db_name' => 'DB_CALCETTO',    'db_table' => 'tb_loghi');

class 
CustomUploadHandler extends UploadHandler {
    protected function 
initialize() {        $this->db = new mysqli(            $this->options['db_host'],            $this->options['db_user'],            $this->options['db_pass'],            $this->options['db_name']        );        parent::initialize();        $this->db->close();    }

   protected function 
handle_form_data($file$index) {        
//$file->title = @$_REQUEST['title'][$index];        
//$file->img   = @$_REQUEST['img'][$index];        
$file->sito  = @$_REQUEST['sito'];    
}    

protected function 
handle_file_upload($uploaded_file$name$size$type$error$index null,          $content_range null) {        
$file parent::handle_file_upload($uploaded_file$name$size$type$error$index,       $content_range);       
if (empty(
$file->error)) {            
$stmt "";            
$sql "INSERT INTO ".$this->options['db_table']." (img,sito,dateIn) VALUES (?,?)";
$stmt $this->db->prepare($sql);            
$stmt->bind_param(                
"ss",                
$file->name,                
$file->sito,                
date('Y-m-d H:i:s')            
);            
$stmt->execute();            
$this->db->close();        
}        
return 
$file;    
}
}
$upload_handler = new CustomUploadHandler($options); 
L'INSERT viene eseguita perfettamente.
Ma il problema grande è che non chiude la connessione, ne libera la memoria, ad inserimento eseguito.

Come risolvo?

Grazie mille.