How to get post type archive category title

$category_detail=get_the_category(get_the_ID());//$post->ID
                                foreach($category_detail as $cd)
                                {
                                    $name_category=$cd->cat_name;
                                    $id_category=$cd->term_id;
                                    echo $name_category;

                                }

this code get category name and id you just put a post id

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