alka Posted September 27, 2009 Share Posted September 27, 2009 Hi, I'm a newbie to PHP and have just created a script that stores the IP of visitors into the database (mysql)... I used the below query to save the information: mysql_query("INSERT INTO tracked_data (tid,rip) VALUES ('$id', INET_ATON('$ip'))"); So far so good... However now I need to query it from MySQL and im completely lost.. Here is what I have working without using INET_NTOA to convert the IP back. $query = mysql_query("SELECT id, tid, rip, curl, datetime FROM tracked_data WHERE tid='$ttid'"); for ($i = 0; $i < mysql_num_rows($query); $i++) { $sid = mysql_result($query, $i, "id"); $tid = mysql_result($query,$i, "tid"); $rip = mysql_result($query, $i, "rip"); $curl = mysql_result($query, $i, "curl"); $datetime = mysql_result($query, $i, "datetime"); echo "$sid | $tid | $rip | $curl | $timedate"; echo "<br>"; Again the stuff above works like it should, but question is how/where do I add INET_NTOA to convert the IP back.. I'm completely lost.. tested a few things but all generate errors... All help is appreciated . Link to comment https://forums.phpfreaks.com/topic/175685-solved-fetching-ip-addresses-from-mysql-stored-with-inet_aton/ Share on other sites More sharing options...
Zane Posted September 27, 2009 Share Posted September 27, 2009 SELECT id, tid, INET_NTOA(rip) as rip, curl, datetime FROM tracked_data WHERE tid='$ttid'"); Link to comment https://forums.phpfreaks.com/topic/175685-solved-fetching-ip-addresses-from-mysql-stored-with-inet_aton/#findComment-925800 Share on other sites More sharing options...
alka Posted September 28, 2009 Author Share Posted September 28, 2009 Ah.. see I knew it was something simply I was missing.. lol.. I tried INET_NTOA(rip), but dont' have enough knowledge yet to know how, why and what as does in this statement... Thanks a bunch for the quick response. I'll go and read on mysql queries.. . Link to comment https://forums.phpfreaks.com/topic/175685-solved-fetching-ip-addresses-from-mysql-stored-with-inet_aton/#findComment-926239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.