try using inet_ntoa() function.


On Thu, 23 Aug 2001 12:19:54 -0700
Jamil Farshchi <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> I am trying to convert a hex number that is stored in a mysql db into an ip 
> address. Here is my problem: I can convert the original integer into a hex 
> number like so:
> 
> For example:
> mysql> select distinct HEX(ip_src) from iphdr;
> -----------
> |ip_src    |
> -----------|
> |80B7EB99  |
> |----------
> 
> Now, I need mysql to parse the hex number and then convert the parsed data 
> into base 10. For example:
> 
> 80B7EB99 (hex) = 128.183.235.153
> to convert the hex into the ip address, we need to do this:
> 80 (hex) = 128
> B7 (hex) = 183
> EB (hex) = 235
> 99 (hex) = 153
> 
> so I need mysql to parse the hex number into 4 parts, convert each part 
> from hex to base 10, and then add a "." between each base 10 number.
> 
> I know how to do this in perl, but I was wondering if it was possible to do 
> strictly in mysql. I really hope so because it would help out a lot.
> 
> Any help would be greatly appreciated,
> -jamil
> 
>----------------------------------------------------------------------------------------------------
> Jamil D. Farshchi
> Computer Specialist, Inspections and Assessments
> NASA Office of Inspector General
> Washington, DC  20546
> Phone: (202) 358-1897 
> 
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to