List categories assigned to a post

You can use get_the_category( ) instead.

Example:

$categories = get_the_category();
foreach( $categories as $category) {
    $name = $category->name;
    $category_link = get_category_link( $category->term_id );

    echo "<a href="https://wordpress.stackexchange.com/questions/249463/$category_link">
            <span class=" . esc_attr( $name) . "></span>
         </a>";
}

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