Noob looking for some help with first useful piece of code

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
Lotmr
Forum Newbie
Posts: 2
Joined: Sat Nov 22, 2003 2:30 pm

Noob looking for some help with first useful piece of code

Post 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
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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>
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

http://www.php.net/manual

Bookmark and study. =)
Post Reply