We help IT Professionals succeed at work.

What is max length of an ip address?

Hi - I am creating a table to log user sessions.  I intend to retrieve the ip address and browser type via php's $_SERVER ['REMOTE_ADDR'] and $_SERVER ['HTTP_USER_AGENT'] variables.

What is the max length of an ip address?  Also, what is the max length of the browser type variable?

Thanks!

Comment
Watch Question

Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009
Commented:
ip adress can only be xxx.xxx.xxx.xxx at least with ipv4 (the current standard)...

the full HTTP_USER_AGENT list:
http://www.siteware.ch/webresources/useragents/db.html

Commented:
ip adress

xxx.xxx.xxx.xxx

instead of trying to figure out the max length for
HTTP_USER_AGENT, cause only someone who has used every browser out there would know that
try something like this instead.
<?PHP
$brouwser = $_SERVER['HTTP_USER_AGENT'];
 
if(strstr($brouwser,"NT 5.1"))
$os = "Microsoft WindowsXP";
 
if(strstr($brouwser,"NT 5.0"))
$os = "Microsoft Windows2000";
 
if(strstr($brouwser,"MSIE 5.0"))
$brouwser = "Microsoft Internet explorer v5.0";
 
if(strstr($brouwser,"MSIE 5.5"))
$brouwser = "Microsoft Internet explorer v5.5";
 
if(strstr($brouwser,"MSIE 6.0"))
$brouwser = "Microsoft Internet explorer v6.0";
 
?> 

Open in new window

Author

Commented:
great - thanks!