Fixed some PHP and SQL stuffs