[thelist] PHP brainleak
Christopher Joseph
Christopher at ideadesigners.com
Tue Mar 19 17:38:08 CST 2002
Hi all,
I am trying to include() a browser detection script but I cannot seem to
access the browser result variable from my main script. I was sure I had the
variable scope thing pegged down but I guess not.....
heres the code:
from index.php[
$browse = "new";
if ($detection <> "detected"){
global $browse;
include ("browserdetect.php");
include ("OSdetect.php");
setcookie("detection", "detected");
}
]
from browserdetect.php[
$browse = getenv("HTTP_USER_AGENT");
if (preg_match("/MSIE/i", "$browse")){
$query = "UPDATE counter SET count = count + 1 WHERE name='MSIE'";
$database->openConnectionNoReturn($query);
}
elseif (preg_match("/Mozilla/i", "$browse")){
$query = "UPDATE counter SET count = count + 1 WHERE name='Netscape'";
$database->openConnectionNoReturn($query);
}
else {
$query = "UPDATE counter SET count = count + 1 WHERE name='Unknown'";
$database->openConnectionNoReturn($query);
}
]
Any thoughts why when I echo $browse it shows as "new" still. Have a very
reall feeling I am being dumb!
Chris.
More information about the thelist
mailing list