How do I display the grand child items of a taxonomy term?

I managed to answer this question myself by adding get_queried_object()->term_id; instead of the taxonomy terms ID. It now outputs all the grandchild taxonomy terms for the current taxonomy term.

Here is my updated working code:

$term_id = get_queried_object()->term_id;
$taxonomy_name="product_range";
$term_children = get_term_children( $term_id, $taxonomy_name );
echo '<ul>';
foreach ( $term_children as $child ) {
$term = get_term_by( 'id', $child, $taxonomy_name );
echo '<li><a href="' . get_term_link( $child, $taxonomy_name ) . '">' . $term->name . '</a></li>';
}
echo '</ul>';

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