SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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">
    	<head>
    		<title>Form Example</title>
    		<meta http-equiv="content-type"
    			content="text/html; charset=uft-8"/>
    	</head>
    		<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">
    	<head>
    		<title>Form Example</title>
    		<meta http-equiv="content-type"
    			content="text/html; charset=utf-8"/>
    	</head>
    	<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. #2
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    index.php

    else3 this is the error
    my mobile portal
    ghiris.ro

  3. #3
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and in form.html.php the file should start with the <?php ?> tags
    my mobile portal
    ghiris.ro

  4. #4
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and in form.html.php and welcome.html.php the files should start with the <?php ?> tags
    my mobile portal
    ghiris.ro

  5. #5
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    note to admin I can't edit my posts
    my mobile portal
    ghiris.ro

  6. #6
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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. #7
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    982
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    MySQL v5.1.58
    PHP v5.3.6

  8. #8
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BrandonK View Post
    form and welcome are correct. You don't need any additional <?php tags.
    I just realized that.
    my mobile portal
    ghiris.ro


Bookmarks

Posting Permissions

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