SQL sytax error - on what?
I'm hoping we have some sql wizzes in here who can help me with this one. I've been boggled for hours trying to find a solution but it looks like there isn't much out there to help define my specific issue. Anyways - I am using geolocation to find coordinates via iphones and then use those coordinates to call from a database of nearby locations.
I had a simple method planned to set the accuracy but I cant figure out why im getting held up in the syntax. Anyways - here would be the code in question:
$ulat = $_GET['glat'];
$ulong = $_GET['glong'];
$latpos = 0;
$longpos = 0;
//
if($ulat < 0){
$latpos = -1;
$ulat = ($ulat*-1);
}else{
$latpos = 1;
}
if($ulong < 0){
$longpos = -1;
$ulong = ($ulong*-1);
}else{
$longpos = 1;
}
$latrangetop = $ulat + 0.01;
$latrangebottom = $ulat - 0.01;
$longrangetop = $ulong + 0.01;
$longrangebottom = $ulong - 0.01;
?>
<table>
<?php
// HERE IS THE SQL STRING THAT I GET AN ERROR ON
$lstring = "SELECT * FROM locations WHERE latpos = ".$latpos." AND longpos = ".$longpos." AND lat > ".$latrangebottom." AND lat < ".$latrangetop." AND long > ".$longrangebottom."";
//END OF ERROR STRING
$lq = mysql_query($lstring) or die(mysql_error());
while($la = mysql_fetch_array($lq)){
echo "<tr><td>".$la['name']."</td></tr>";
}
?>
</table>
The exact error I get is:
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 'long > 22.33333' at line 1 |
-
Marketing Profits Software -
[ 1 ] Thanks - 1 reply
{{ DiscussionBoard.errors[2296971].message }}-
Krisism -
Thanks
{{ DiscussionBoard.errors[2297081].message }} -
-
-
Marketing Profits Software -
Thanks
{{ DiscussionBoard.errors[2297135].message }} -