Removed mysql from more php files and stored them as procedures and functions