1. ## Spot the mistake

I'm working my way through the tutorial in chapter 3 of Kevin Yank's 'Build Your Own Database Driven Website using PHP and MySQL' and when I check

http://localhost/welcome/

I get:

Parse error: parse error in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\welcome\index.php on line 7

The 3 associated files are:
1. welcome.html.php
2. index.php
3. form.html.php

I'll include all the relevant code below and would appreciate if someone can spot the mistake, as I have gone over it many times with no luck!

welcome.html.php
Code:
```<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>Form Example</title>
<meta http-equiv="content-type"
content="text/html; charset=uft-8"/>
<body>
<p>
<?php
echo \$output;
?>
</p>
</body>
</html>```
index.php
Code:
```<?php
if (!isset(\$_REQUEST['firstname']))
{
include 'form.html.php';
}
else3
{
\$firstname = \$_REQUEST['firstname'];
\$lastname = \$_REQUEST['lastname'];
if (\$firstname == 'Kevin' and \$lastname == 'Yank')
{
\$output = 'Welcome, oh glorious leader!';
}
else
{
\$output = 'Welcome to our web site, ' .
htmlspecialchars(\$firstname, ENT_QUOTES, 'UTF-8') . ' ' .
htmlspecialchars(\$lastname, ENT_QUOTES, 'UTF-8') . '!';
}
include 'welcome.html.php';5
}
?>```
form.html.php
Code:
```<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>Form Example</title>
<meta http-equiv="content-type"
content="text/html; charset=utf-8"/>
<body>
<form action="" method="post">
<div><label for="firstname">First name:
<input type="text" name="firstname" id="firstname"/></label>
</div>
<div><label for="lastname">Last name:
<input type="text" name="lastname" id="lastname"/></label>
</div>
<div>
<input type="submit" value="GO"/>
</div>
</form>
</body>
</html>```

2. index.php

else3 this is the error

3. and in form.html.php the file should start with the <?php ?> tags

4. and in form.html.php and welcome.html.php the files should start with the <?php ?> tags

5. note to admin I can't edit my posts

6. Hi Ernie

I thought it was the else3 in index.php as well, but that is exactly what the tutorial states. I also didn't understand the '5' at the end of the include in the same file?

form.html.php contains no php, so why the need for the <?php ?> tags?

welcome.html.php has <?php ?> tags, but only around the php as per the tutorial. Is this incorrect?

7. The 5's gotta go too. They are rendering errors, so either the tutorial copy and pasted wrong, or their CMS had a small rendering hiccup.

form and welcome are correct. You don't need any additional <?php tags.

8. Originally Posted by BrandonK
form and welcome are correct. You don't need any additional <?php tags.
I just realized that.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•