What is my error in my module? Only use hook_cron
I have the following error: When i create a new node from the new data of my db external (When insert a new row in the DB) this new node is duplicated (But this node duplicated don't have type, language, user.. nothing) and for this bug of that duplicate node gives me the following error: 

    Invalid argument supplied for foreach() en /path/web/my_proyect/sites/all/modules/cck/content.module en la línea 1284.

I don't know the reason for this. I debug my code and.. I don't know where duplicate the data.

This is my code of my module (only use the hook_cron because this is my proyect)

    /* Implement of Hook_cron */
    function node_db_extension_cron(){
         inspectAddHoteles();
         drupal_flush_all_caches();
    }
    
    function getHotelFromDrupal() {
        $type = '[my_type]';
        $query_nid = "SELECT count(nid) count FROM node WHERE type LIKE '%s'";
        $result_start = db_query($query_nid, $type);
        $cantidad = 0;
        
        while ($row = db_fetch_object($result_start)) {
            $cantidad = (int) ($row->count);
        }
    
        return $cantidad;
    }
    
    function getHotelFromExternal() {
        db_set_active('external');
        
        $result = db_query("SELECT count(id) count FROM [my_table]");
        $cantidad = 0;
        
        while ($row = db_fetch_object($result)) {
            $cantidad = (int) ($row->count);
        }
        
        db_set_active('default');
        
        return $cantidad;
    }
    
    function inspectAddHoteles() {
        global $user;
        
        $cantd_actual_hotel = getHotelFromDrupal();
        $cantd_final_hotel = getHotelFromExternal();
        
        /* With the count of nid of drupal and id of db external, i verify if exist new rows  because the count of nid of content and id of rows of my db externa should be equals if don't exists new rows on my db external */
        
        if ($cantd_actual_hotel < $cantd_final_hotel) {
            db_set_active('external');
            
            $cant_add = $cantd_final_hotel - $cantd_actual_hotel;
            $query = "SELECT * FROM [my_table] ORDER BY id DESC LIMIT %d";
            $additional = db_query($query, $cant_add);
            
            db_set_active('default');
            
            while ($row = db_fetch_object($additional)) {
                $node = new stdClass();
                
                $node->uid = $user->uid;
                $node->type = 'my_type';
                $node->title = $row->title;
                $node->body = $row->body;
                $node->created = time();
                $node->changed = $node->created;
                $node->promote = 0;
                $node->sticky = 0;
                $node->format = 2;
                $node->status = 1; 
                $node->language = 'es';
                //All field of my content type
                
                $nodo_1 = node_submit($node);
                node_save($nodo_1);
            }
        }
    }

Thanks :D
What is my error in my module? Only use hook_cron
===

I have the following error: When i create a new node from the new data of my db external (When insert a new row in the DB) this new node is duplicated (But this node duplicated don't have type, language, user.. nothing) and for this bug of that duplicate node gives me the following error: 

    Invalid argument supplied for foreach() en /path/web/my_proyect/sites/all/modules/cck/content.module en la línea 1284.

I don't know the reason for this. I debug my code and.. I don't know where duplicate the data.

This is my code of my module (only use the hook_cron because this is my proyect)

    /* Implement of Hook_cron */
    function node_db_extension_cron(){
         inspectAddHoteles();
         drupal_flush_all_caches();
    }
    
    function getHotelFromDrupal() {
        $type = '[my_type]';
        $query_nid = "SELECT count(nid) count FROM node WHERE type LIKE '%s'";
        $result_start = db_query($query_nid, $type);
        $cantidad = 0;
        
        while ($row = db_fetch_object($result_start)) {
            $cantidad = (int) ($row->count);
        }
    
        return $cantidad;
    }
    
    function getHotelFromExternal() {
        db_set_active('external');
        
        $result = db_query("SELECT count(id) count FROM [my_table]");
        $cantidad = 0;
        
        while ($row = db_fetch_object($result)) {
            $cantidad = (int) ($row->count);
        }
        
        db_set_active('default');
        
        return $cantidad;
    }
    
    function inspectAddHoteles() {
        global $user;
        
        $cantd_actual_hotel = getHotelFromDrupal();
        $cantd_final_hotel = getHotelFromExternal();
        
        /* With the count of nid of drupal and id of db external, i verify if exist new rows  because the count of nid of content and id of rows of my db externa should be equals if don't exists new rows on my db external */
        
        if ($cantd_actual_hotel < $cantd_final_hotel) {
            db_set_active('external');
            
            $cant_add = $cantd_final_hotel - $cantd_actual_hotel;
            $query = "SELECT * FROM [my_table] ORDER BY id DESC LIMIT %d";
            $additional = db_query($query, $cant_add);
            
            db_set_active('default');
            
            while ($row = db_fetch_object($additional)) {
                $node = new stdClass();
                
                $node->uid = $user->uid;
                $node->type = 'my_type';
                $node->title = $row->title;
                $node->body = $row->body;
                $node->created = time();
                $node->changed = $node->created;
                $node->promote = 0;
                $node->sticky = 0;
                $node->format = 2;
                $node->status = 1; 
                $node->language = 'es';
                //All field of my content type
                
                $nodo_1 = node_submit($node);
                node_save($nodo_1);
            }
        }
    }

Thanks :D