Output a specific link in WordPress post if the single post’s category’s name contain certain word

You should remove the single quotes around the expression otherwise it will be treated as a string.

$firstCategory = '$category[0]->cat_name';

Should be changed to:

$firstCategory = $category[0]->cat_name;

Then you can try basic debugging like printing the output of the $category and $category[0]->cat_name.

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