Problem with select statement

I am playing around with php and mysql, trying to learn something. I have a small php page that uses this to collect ip adresses:

$ipaddress =$_SERVER['REMOTE_ADDR'];

I want to use the Ip to country database to correlate the Ip adress with a country. I have imported the country database. In trying to match Ip adress with data in the Country database I use this:

$result = mysqli_query($link,"SELECT countryLONG FROM IPCountry WHERE '". $ipaddress . "' BETWEEN ipFROM AND ipTO");
if (!$result)
$error = 'Error fetching country: ' . mysqli_error($link);
include 'included/error.html.php';
while ($row = mysqli_fetch_array($result))
echo $row['countryLONG'];

countryLONG is a field in the the IPCountry table with country names. ipFROM and ipTO are IP ranges. All I get is a blank page.

It works. I had forgot to convert the ip adresses to numbers…:blush:

I don’t believe BETWEEN will work well in your case.

Why don’t you use the INET_ATON() function;

Corrected that during your posting, men it does not solve the problem.

In your while loop you have $rows instead of $row