How to access a table I inserted manually into Drupal 7 db
You shouldn't do  a query from a .tpl.php or include any php logic there. If you have to do it in the theme (this would be better in a small custom module), do it in the template.php in a preprocess function (node or page preprocess, depending on what template you want your variable available). 

So you do your query in the template.php file and then through a preprocess function send the variable to your .tpl.php files.

I also don't recommend writing MySQL queries in Drupal, you should use the Drupal API for this. Drupal has a database abstraction layer that gives you lots of handy function you can use.