We help IT Professionals succeed at work.
Get Started

PHP MySQL find IP address (between) stored IP address ranges

dev09
dev09 asked
on
149 Views
Last Modified: 2015-08-24
Hi,

I am wondering how to code a PHP MySQL 'SQL' query to find the given IP address between 2 stored IP address ranges.

I am trying this:
$theIp  = 'xxx.xxx.xxx.xxx';
$result = mysqli_query($link,"SELECT * FROM `ipAddresses` WHERE `start` <= '$theIp' AND `end` >= '$theIp'") or die(mysql_error());

But it doesn't seem to be working correctly.  Should i store the IP data differently? Not in one field.

Thanks in advance!
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE