get_permalink to attachment not working

The Problem is that you query for Post Status null. Try setting this to publish or inherit, because get_permalink is a function for published items, not for any post status.

This is because Permalinks to items with a status like draft should not be shown to the user.

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