Need to return a string as permalink insted of str_replace

Use get_term_link() to get the correct URL for a taxonomy term archive.

$list .= "\n\t\t" . '<li><a href="'. get_term_link( $tag ) .'">'.$name.'</a></li>';

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