Moved the MySQL connection code to a function on the functions php document.
Minor formatting