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

  • Home
  • SEARCH
  • 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 6550829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:15:49+00:00 2026-05-25T12:15:49+00:00

I am developing a real estate script. The script has a search option where

  • 0

I am developing a real estate script. The script has a search option where an user can specify the price range eg. user_price_low to user_price_high and the listings have to be fetched from a database, which has eg. db_price_high and db_price_low.

I used a BETWEEN statement trying to find the matches,

WHERE price_low BETWEEN '.$_REQUEST['minprice_buy'].' AND '.$_REQUEST['maxprice_buy']

but to my surprise…

If an user has user_price_high = 60 and user_price_low = 20
AND
the record has db_price_low = 30 and db_price_high = 120

my query is invalid in this case.

i tried looking at MySql Query- Date Range within a Date Range but does that match what I want?

  • 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-05-25T12:15:49+00:00Added an answer on May 25, 2026 at 12:15 pm

    Chandan, never ever input $_* functions directly into a query. It’s an SQL-injection hole.

    Change the code to:

    $min_price = mysql_real_escape_string($_REQUEST['minprice_buy']);
    $max_price = mysql_real_escape_string($_REQUEST['maxprice_buy']);
    $query = "SELECT whatever 
              FROM whichever 
              WHERE price_low BETWEEN '$min_price' AND '$max_price' ";
    // Dont forget these quotes       ^          ^     ^          ^
    // Or mysql_real_escape_string() will not work!.
    

    With regards to your question, change the query to something like:

    WHERE '$min_price' BETWEEN price_low AND price_high 
      AND '$max_price' BETWEEN price_low AND price_high
    

    You may also want to consider:

    WHERE ('$min_price' BETWEEN price_low AND price_high) 
      OR  ('$max_price' BETWEEN price_low AND price_high)
    

    Here min_price and max_price don’t need to both be in the range at all times.

    See: How does the SQL injection from the "Bobby Tables" XKCD comic work?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an application which requires real-time updates to the end user. However,
When developing software that records input signals (numbers) in real time, how can this
I'm developing an iPhone (and later Android) app that has real-time features, i.e. when
i am developing an application for a real-estate company. the problem i am facing
While developing with Fluent nHibernate, I notice that on relationships I can specify a
I'm developing MVC engine for real estate web-site from scratch. Currently I have this
I'm developing a real time strategy game clone on the Java platform and I
Developing a .NET WinForms application: how can I check if the window is in
We have a large real-estate of existing SSRS 2008 reports that we are still
I am developing an application that processes images captured in real time by a

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.