Clean up the code for better reading

This code cannot be used for PHP > version 5.5. or if mysql_query
extension is not enabled!