views:

31

answers:

1

I'm still working on the whole gathering user data from a visit thing, so I'm hung up on grabbing the actual name of the browser being used by the visitor. I have this code, but it seems that after execution, $browser is empty.

  $userAgent = mysql_real_escape_string($_SERVER["HTTP_USER_AGENT"]);
  $browser = get_browser($userAgent, true);
  print_r($browser);

What am I doing wrong here, and what steps do I take next to extract the browser from the array?

EDIT

Okay so now I have the following code:

  $browser = get_browser(null, true);
  $userAgent = $browser["browser"];
  $browser = mysql_real_escape_string($userAgent);
  echo $browser;

Which does nothing. Any insight?

+2  A: 

According to php.net when first parameter of get_browser is set to null then default "the value of HTTP User-Agent header is used". So look at this code.


$browser = get_browser(null,true);
$userAgent = $browser["browser_name_pattern"];
Ventus