0

What could be wrong with this line:

'$query = "SELECT * FROM messages WHERE (rlat => '".$latmin."' AND rlat <= '".$latmax."')      AND (rlon >= '".$lonmin."' AND rlon <= '".$lonmax."')";'

Error: Error in query: SELECT * FROM messages WHERE (r_lat => '55.4655951769' AND r_lat <= '55.496987423') AND (r_lon >= '25.5338700398' AND r_lon <= '25.5989507602'). You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=> '55.4655951769' AND r_lat <= '55.496987423') AND (r_lon >= '25.5338700398' AN' at line 1...

Thanks!

000
  • 26,951
  • 10
  • 71
  • 101
Saulius s
  • 601
  • 2
  • 9
  • 18

1 Answers1

3

=> isn't a known operator. If you want the greater than or equal comparison operator, then you are after >=.

Incidentally, you might find that your query can be written more concisely with the BETWEEN ... AND ... operator:

SELECT *
FROM   messages
WHERE  rlat BETWEEN $latmin AND $latmax
   AND rlon BETWEEN $lonmin AND $lonmax

You should also investigate passing variables into your SQL by way of parameters to prepared statements.

Community
  • 1
  • 1
eggyal
  • 122,705
  • 18
  • 212
  • 237