getting parser error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bruceg
Forum Contributor
Posts: 174
Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:

getting parser error

Post by bruceg »

I am getting an error on my page trying to determine what browser/platform a user is on.

the error is:
Parse error: parse error, unexpected '\"' in /hsphere/local/home/bruceg/inspired-evolution.com/Browser_Identification.php on line 39

and the page is question is at:

http://www.inspired-evolution.com/Brows ... cation.php

the code is as following:

Code: Select all

<?php $viewer = getenv ( "HTTP_USER_Agent" );

	$Browser ="an unidentified browser";
	if (preg_match( "/MSIE/i", "$viewer" ) )
			{$browser="Internet Explorer"; }
	else if (preg_match( "Netscape/i", $viewer" ) )
			{$browser="Netscape";  }
	else if (preg_match( "/Opera/i", $viewer" ) )
			{$browser="Opera";  }
	else if (preg_match( "/Mozilla/i", $viewer" ) )
			{$browser="Mozilla";  }
	else if (preg_match( "/Firefox/i", $viewer" ) )
			{$browser="Firefox";  }
	else if (preg_match( "/Mozilla/i", $viewer" ) )
			{$browser="Mozilla"; }
	$platform = "an unidentified operating system" ;
	if ( preg_match( "/Windows/i", "$viewer" ) )
		{ $platform="windows"; }
	else if(preg_match( "/Macintosh/i" , "$viewer" ) )
		{ $platform ="Macintosh";  }
	echo ( "<p>You're using $browser on $platform</p>" );
?>
can anyone see where the error is???

thx,
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

for starters:

HTTP_USER_Agent should be HTTP_USER_AGENT:

secondly, a lot of missing quotes around $viewer you have.

$viewer should not be quoted at all, in reality however...

ex:

Code: Select all

if(preg_match("/msie/i",$viewer)){
  // do IE
}
Post Reply