Save the Post ID from wp_insert_post($post); into a text file?

You use add_action!

Like this:

function save_id_to_file($post_id){
 //use your file creation/save function here
 return $post_id;
}

add_action('wp_insert_post','save_id_to_file');

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)