wp_update_post gives 500 internal error

Try using save_post hook instead.

Check this example:
https://gist.github.com/fgilio/38dfbf9d03654b21302a

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