Page 1 of 1

Noob looking for some help with first useful piece of code

Posted: Sat Nov 22, 2003 2:30 pm
by Lotmr
Hi,
I just started playing around with PHP about, 45 minutes ago and, seeing as im the kind of person who wants to learn what wrong with my code, (even if the code itself is useless) i posted here to see if someone could tell me what im doing wrong, so i dont make the mistake again.

Heres the code:

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
$str = "Your using Inet Explorer<br />"
if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) {
$strtoupper($str);
print $str
}
?>
</body>
</html>

Heres the error:

Parse error: parse error, unexpected T_IF in C:\sokkit\site\test.php on line 8

I have little programming experince although I can code pretty fairly in VB.

Thanks
Lotmr

Posted: Sat Nov 22, 2003 2:38 pm
by infolock
you just forgot 2 ;'s at the end of 2 statements, and also, you don't need the $strtoupper statement at all. I also used ECHO instead of PRINT for your message. So, your code should look like this :

Code: Select all

<html> 
<head> 
<title>PHP Test</title> 
</head> 
<body> 

<?php 
$str = "Your using Inet Explorer<br />";  //added a ;

	if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) 
	{
                                 //deleted $stroupper since you didn't need it
		echo $str;  // added ;
	}
?> 

</body> 
</html>

Posted: Sat Nov 22, 2003 5:00 pm
by m3mn0n
http://www.php.net/manual

Bookmark and study. =)