• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3041
  • Last Modified:

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!

0
shafer23
Asked:
shafer23
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
0
 
nplibCommented:
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

0
 
shafer23Author Commented:
great - thanks!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now