inet_aton()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iano
Forum Newbie
Posts: 7
Joined: Fri Jan 09, 2004 6:24 am

inet_aton()

Post by iano »

can you guys tell me what i need to do to get the inet_aton() function to work?

I seem to need some arpa/inet.h file but I can't find it anywhere

thanks guys

the code it's in is:
<? echo inet_aton('$REMOTE_ADDR')
?>
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

inet_aton() is not a php function but rather a inbuildt (?) *nix one. Looks like someone is trying to mix c and php...

What are you trying to do really?
iano
Forum Newbie
Posts: 7
Joined: Fri Jan 09, 2004 6:24 am

Post by iano »

I'm trying to convert a user's ip address, then look in a database for the corresponding country and then output the country.
Here's the whole set of code for context:
// Establishing a database connection
$dbh=mysql_connect("localhost","$username","$password");
mysql_select_db("$username");


// Query for getting visitor countrycode
$country_query = "SELECT country_code2,country_name FROM iptoc ".
"WHERE IP_FROM<=inet_aton('$REMOTE_ADDR') ".
"AND IP_TO>=inet_aton('$REMOTE_ADDR') ";


// Executing above query
$country_exec = mysql_query($country_query);


// Fetching the record set into an array
$ccode_array=mysql_fetch_array($country_exec);


// getting the country code from the array
$country_code=$ccode_array['country_code2'];


// getting the country name from the array
$country_name=$ccode_array['country_name'];


// Display the Visitor coountry information
echo "$country_code - $country_name";


// Closing the database connection
mysql_close($dbh);
Post Reply