Getting the top level permalink using get_post_ancestors()

You may want to try get_permalink() ie: get_permalink( end($parents) ). 🙂

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