Jump to content

[SOLVED] Fetching IP addresses from MySQL stored with INET_ATON


alka

Recommended Posts

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 :).

 

 

 

 

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.. :).

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.