How do i set global variable in a function in wordpress functions.php

Declare $a as a global variable, just as you have with $post:

global $post, $a;

(Keep in mind, you may collide with other variables, since your var name is not really all that unique)

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