Fixed small errors between PHP versions and added SQL