use functions.php with ranking
close mysql connections properly