but I get same result everytime.
the counter is increasing, and query seem to work first time, but the rest of the loop run sql query will return same result.
any ideas?
Thanks
Code: Select all
<?php
$ipaddress = $_POST['IP'];
$ipaddress = nl2br($ipaddress);
$ip_array = explode ("<br />", $ipaddress);
$counter = 0;
$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = 'SELECT
c.country
FROM
ip2nationCountries c,
ip2nation i
WHERE
i.ip < INET_ATON("'.$ip_array[$counter].'") AND c.code = i.country
ORDER BY
i.ip DESC
LIMIT 0,1';
echo "Your IP is ";
echo $_SERVER['REMOTE_ADDR'];
echo "<p>---------------------------------</p>";
foreach ($ip_array as $search) {
list($countryName) = mysql_fetch_row(mysql_query($sql));
echo $countryName;
echo " ----------";
echo $sql;
$counter++;
}
?>