made changes to sql.php and importsql.php - changed everything to functions