[thelist] PHP brainleak
jon steele
jjsteele22 at yahoo.com
Tue Mar 19 20:39:00 CST 2002
Your code looks ok to me. Is OSDetect.php using a variable named $browse?
"global $browse" is not needed either.
Again, I don't see any problem with your code...$browse should be accessible by your main script
as used in browserdetect.php
Jon
--- Christopher Joseph <Christopher at ideadesigners.com> wrote:
> 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.
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !
__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/
More information about the thelist
mailing list