Tag custom loop show posts

It is not recommended to use query_posts. But this is not the problem, Problem is you are using PHP variable in single quotes. 'tag=$tag'

Consider these examples:

query_posts('tag=php');
//OR
query_posts("tag=$tag"); //$tag should output: php

Using WP_query //Recommended

$query = new WP_Query(array( 'tag' => 'php' ));

Ref: WP_Query-Tag_Parameters | query_posts

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