Help to cleanup this code

get_post returns a WP_Post object, so you can retrieve the post parent with $post->post_parent. You should have a look at the member variables in the WP_Post link.

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