Database SQL Error, Should Work

Not sure about DB connection but there seems some syntax issue.

lat and lng have been used unlike PHP variables at some places in your code. I believe, they should have been $lat and $lng respectively instead.