Term name of current node in title
Your code is using the following line:

$terms_name = print $term_name-&gt;name;


You are assigning to $terms_name the value returned by print $term_name-&gt;name, which is 1.
If you try executing $var = print "ciao";, you will notice that the value assigned to $var is 1.

The other issue with that code is that $term_name is not a variable defined from the code you showed; executing that code, you get an "access to a not defined variable" error.