Performance impact of using global $post

There is no significant difference. Both will use a cached version of the current $post, in one you will access it via global $post, in other via functions that will get the data from the $post in the cache. I would suggest moving the in_the_loop() condition to be first in the IF.

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