WordPress taxonomy code not working in PHP 5.5

The code used to work in PHP 5.4 but refuses in PHP 5.5. Can’t find the error in the code. Checked the migration guide but don’t see any issues. Feeling this has to do with depreciation of mysql in PHP 5.5 and need to be replaced with mysqli. However, mysql is not directly used in this PHP script.

<?php global $wpdb;
$cterm = get_query_var(taxname(get_the_id()));
$taxonomyName = taxname(get_the_id());
$terms = get_terms($taxonomyName,array('parent' => 0));

foreach($terms as $term) {
  echo '<li>';
  echo '<a rel="'.$term->term_id.'" href="'.get_term_link($term->slug,$taxonomyName).'">'.$term->name.'</a>';

  $term_children = get_term_children($term->term_id,$taxonomyName);
  echo '<ul class="insertedList">';

  foreach($term_children as $term_child_id) {
     $term_child = get_term_by('id',$term_child_id,$taxonomyName);
     echo '<li><a rel="'.$term_child->term_id.'">' . $term_child->name . '</a></li>'; 
  } echo '</ul></li>';
} ?>

Related posts