SQL fixes and php GET api