function getcountry($ip)
{
global $user, $password, $db, $server;
$dbh = mysql_connect($server, $user, $password);
mysql_select_db("$db");
$country_exec = mysql_query("SELECT code FROM ips WHERE ip1<='$ip' AND ip2>='$ip'");
$ccode_array = mysql_fetch_array($country_exec);
$result = $ccode_array['code'];
mysql_close($dbh);
if (empty($result)) $result = 1;
return $result;
}