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 9129945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:51:45+00:00 2026-06-17T07:51:45+00:00

I started a PHP side project a while back, and recently started cleaning up

  • 0

I started a PHP side project a while back, and recently started cleaning up all the code and updating it. Part of that is moving things to start using PDO for DB queries. In one particular query I have a WHERE clause statement that uses the BETWEEN clause along with the INET_ATON() function. So far I have not been able to get this to work properly and would appreciate if anyone can point out whether or not it will even work.

I found this question which leads me to believe that the BETWEEN statement is not having any issues, but I fear it might be the combination with the function causing the issue.

Here is what that portion of my query looks like:

SELECT foo, bar FROM table JOIN more_table 
WHERE item1 = :value AND ip_address BETWEEN INET_ATON(:ipstart) AND INET_ATON(:ipend)

The actual query is quite a bit larger than that, but for basics this works. To replace the tokens with the actual values I have the following foreach loop set up (the var_dump is just there so i can verify the correct values are getting passed in, which they are):

foreach($p as $k=>$v) {
    echo var_dump($k, $v);
    if(is_int($v)){
        $querySubmit->bindValue($k, $v, PDO::PARAM_INT);
    } else {
        $querySubmit->bindValue($k, $v, PDO::PARAM_STR);
    }
}

If anyone knows whether PDO::Prepare and PDO::bindValue have any limitations with a query set up to use BETWEEN and INET_ATON(), I would greatly appreciate knowing!

  • 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-17T07:51:46+00:00Added an answer on June 17, 2026 at 7:51 am

    The issue ended up being with a separate section of code. The values being passed into the SQL query were correct, and the bindValue operation was working successfully.

    To anyone who reviews this question in the future, who believes they are having a similar problem, if set up correctly there should be no issues with using the INET_ATON/NTOA() functions with BETWEEN.

    I believe the first comment, left by @MarcB, was probably the best answer to this actually, “PDO has absolutely NO knowledge of MySQL functions. as long as the MySQL parser doesn’t reject the query string, PDO will happily shove in whatever you want, wherever you want it.”

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

Sidebar

Related Questions

I'm getting started with a side project that will be developed using PHP and
I just started using php arrays (and php in general) I have a code
I recently started with PHP Object Oriented and I cannot seem to get this
Recently the PHP manual started showing the following warning on every mysql function page:
I have recently started programming in PHP. I am building a cart in PHP.
I started doing a new project in PHP / MySql . The Aim of
I've just started messing around with php recently and I was testing my new
Well, I just started to work on server side scripting , I chose PHP,
I started learning AJAX recently and am trying a very simple project which involves
The following code recently started returning empty strings. It works on other systems, so

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.