How To Encode Ip Address In Mysql Database With Php



How To Encode Ip Address In Mysql Database With Php
 (382) Find work at Home Jobs
How To Encode Ip Address In Mysql Database With Php
Post Description:
Post Tags: how, to, encode, ip, address, in, mysql, database, with, php
This Post Has Been Viewed 405 Times Since Thu Aug 02, 2007 9:22 am Posted By hostman with 1 replies
Next Post »» how to validate check correct embed code like youtube videos
How To Encode Ip Address In Mysql Database With Php
if you want to insert user information like the user's ip address, but don't want to put the dots in the ip address, there is a better way. like many forums websited, for example, phpbb, they encode the ip address of the poster, so they use this fucnctions to encode and decode, its an effecient way to manage information in your database.

here and example:

CODE:
function encode_ip($dotquad_ip){
	$ip_sep = explode('.', $dotquad_ip);
	return sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]);
}
function decode_ip($int_ip){
  $hexipbang = explode('.', chunk_split($int_ip, 2, '.'));
  return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]);
} 

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About How To Encode Ip Address In Mysql Database With Php




:: 1 :: #13733 - Reply By tacal On Thu Aug 02, 2007 10:40 am
very good information