SELECT id,idforeca,(((acos(sin((*pi()/180)) * sin((lat*pi()/180))+cos((*pi()/180)) * cos((lat*pi()/180)) * cos(((- lng)*pi()/180))))*180/pi())*60*1.1515*1.609344) as distancia FROM localidadesforeca order by distancia ASC LIMIT 0,20
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '*pi()/180)) * sin((lat*pi()/180))+cos((*pi()/180)) * cos((lat*pi()/180)) * cos((' at line 1