How to write a new file when new post has been published in WordPress

Where you pass post id ?

 $content = htmlentities(get_post_field('post_content', $post_ID));

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