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

 

 

 

 

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.