Having trouble with SitePoint tutorial

Hello - I’ve been reading and following the “Build Your Own Database Driven Web Site using PHP & MySQL” tutorial - I have been following (and practising the examples) just fine up until this page:

This page includes 2 examples on how use “PHP templates” - the first example on the page works just fine, however I am having trouble with the second example - I have created the 3 separate files as described, and copied and pasted the content exactly as written - however when I launch index.php (through Apache) by typing http://localhost/welcome/ I get the following error

“Parse error: syntax error, unexpected ‘{’ in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\welcome\index.php on line 7”

Does anyone have any ideas?

I’m not sure why it’s complaining about the open bracket in that file as the syntax all seems correct and has been copies exactly from the tutorial on the webpage.


It seems some numbers crept up in that code that shouldn’t be there:

if (!isset($_REQUEST['firstname']))    
 include 'form.html.php';    
 $firstname = $_REQUEST['firstname'];    
 $lastname = $_REQUEST['lastname'];    
 if ($firstname == 'Kevin' and $lastname == 'Yank')    
   $output = 'Welcome, oh glorious leader!';    
   $output = 'Welcome to our web site, ' .    
       htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . ' ' .    
       htmlspecialchars($lastname, ENT_QUOTES, 'UTF-8') . '!';    
 include 'welcome.html.php';[COLOR="Red"][B]5[/B][/COLOR]    

Remove the numbers 3 and 5 I indicated in bold red above and you should be fine :slight_smile:

I did think they looked suspect!

Thanks for the quick reply!