Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8125719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:54:27+00:00 2026-06-06T06:54:27+00:00

I have a problem that has been driving me batty. I have code that

  • 0

I have a problem that has been driving me batty. I have code that passes coordinates to a query function. The query works fine for latitude see below, but not longitude. I had a complex WHERE clause for both but moved to separate WHERE clauses for the two to troubleshoot. The code below shows the latitude WHERE commented out. If I reverse the commenting out, latitude works as expected. All values in the referenced database are Doubles and negative for longitude versus all positive for latitude. I have hunted for improper syntax and cannot find it. I have even rounded variables to pass, double checked column names, reversed operators, and plenty else. The two WHEREs are identical, respectively; and the longitude variables are passing cleanly based on the feedback of the error given. So, where’s Waldo? Thank You!

The ERROR:

Database query failed: 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>=-93.497315 AND long<=-91.365967’ at line 1

Calling Function:

$box=$_GET["rect"];
$box=ltrim($box,"((");
$box=rtrim($box,"))");
$boxArray = explode("), (",$box);
$sw = explode(", ",$boxArray[0]);
$ne = explode(", ",$boxArray[1]);
$swLat = round($sw[0], 6);
$swLong = round($sw[1], 6);
$neLat = round($ne[0], 6);
$neLong = round($ne[1], 6);
$job_set = get_job_by_Rectangle($swLat, $swLong, $neLat, $neLong);

while ($job = mysql_fetch_array($job_set)) {
            echo $job["projectFK"] . ", ";}

Problem Function:

function get_job_by_Rectangle($swLat, $swLong, $neLat, $neLong) {
global $connection;
$query = "SELECT * ";
$query .= "FROM projcoords ";
//$query .= "WHERE lat>= " . $swLat . " AND lat<= " . $neLat . " " ;
$query .= " WHERE long>=" . $swLong . " AND long<=" . $neLong . " " ;
//$query .= " ORDER BY projectFK";
$result_set = mysql_query($query, $connection);
confirm_query($result_set);

    return $result_set;
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:54:30+00:00Added an answer on June 6, 2026 at 6:54 am

    LONG is reserved word in MySQL.

    So you need to quote the column name with a backtick:

    $query .= " WHERE `long`>=" . $swLong . " AND `long`<=" . $neLong . " " ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript function that has been driving me nuts. This is the
I have a problem that has been driving me nuts. I create a Form
This problem has been driving me mad. Here's the general gist: I have two
This has been driving me nuts all day. I have a weird bug that
I have a problem that is and has been perplexing me for hours. I
I have a problem which has been driving me mad for days - I've
I a problem that has been driving me nuts for awhile now. Here is
i have this problem that has been buggin me for the last hours. Lets
I have a problem that has been bothering me now for a few days.
I have a problem that has been bothering me for a while. Each child

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.