0

Hi,

I have looked throught his code for about 2 hours now and i cannot seem to find the error. Pelsaae could you tell me where i am going wrong.

Parse error: syntax error, unexpected $end in CreateAccount.php on line 112

<?php

class CreateAccountPage
{

	public function __construct()
	{
		
	}
	
	
	public function title()
	{
		return 'Create Account';	
	}
	
	
	public function inlineStyle()
	{
		return <<<EOSTYLE
		label
		{
			margin-top: 0.5em;
			display: block;
			font-family: Arial, Helvetica;
			font-size: 10pt;
			color: #444;
		}
	EOSTYLE;	
	}
	
	
	public function processRequest()
	{
		//first process any incoming POST data
		if(isset($_POST) and count($_POST) != 0)
			$this->processIncomingFormData();
			
		//now emit page content
		$titleText = $this->title();
		$inlineStyle = $this->inlineStyle();
		
		$this->emitHeaders($titleText, $inlineStyle);
		
		echo "<body>\n";
		
		$this->generateBodyContents();
		
		echo "</body>\n";
		echo "</html>\n";
	
	}
	
	
	protected function generateBodyContents()
	{
		echo <<<EOCONTENTS
		
<h3>Create a New User Account</h3>
	<form method="post" action="SubmitAccountData.php" name="create_user_form">
		<div>
			<label>User Name:</label>
			<input type='text' name='user_name' size='30'>
		</div>
		<div>
			<label>Full Name:</label>
			<input type='text' name='full_name' size='30'>
		</div>
		<div>
			<label>Password:</label>
			<input type='password' name='password1' size='20'>
		</div>
		<div>
			<label>Password (confirm);</label>
			<input type='password' name='password2' size='20'>
		</div>
		<div>
			<label>Email Address:</label>
			<input type='text' name='email_address' size='30'>
		</div>
		<p><input type='submit' value='Create User'></p>
	</form>

EOCONTENTS;
	}
	
	
	protected function emitHeaders($titleText, $inlineStyle)
	{
		echo <<<EOHEADERS
<html>
<head>
	<title>{$titleText}</title>
	<style type='text/css' media='all'>
		body
		{
			font-family: Arial, Hervetica;	
		}
		{$inlineStyle}
	</style>
</head>

EOHEADERS;
	}
	
	protected function processIncomingFormData()
	{
		// enter user page doesn't care about form data	
	}

}
?>
6
Contributors
10
Replies
11
Views
7 Years
Discussion Span
Last Post by abrocketman
1

You have an extra tab character after EOSTYLE; (line 29 in your code above)

Delete that line and retype it, taking care not to add any extra characters after the semi-colon.

Edited by edwinhermann: n/a

0

You have an extra tab character after EOSTYLE; (line 29 in your code above)

Delete that line and retype it, taking care not to add any extra characters after the semi-colon.

I have done the changes and get the same error.

<?php

class CreateAccountPage
{

	public function __construct()
	{
		
	}
	
	
	public function title()
	{
		return 'Create Account';	
	}
	
	
	public function inlineStyle()
	{
		return <<<EOSTYLE
		label
		{
			margin-top: 0.5em;
			display: block;
			font-family: Arial, Helvetica;
			font-size: 10pt;
			color: #444;
		}
EOSTYLE;	
	}
	
	
	public function processRequest()
	{
		//first process any incoming POST data
		if(isset($_POST) and count($_POST) != 0)
			$this->processIncomingFormData();
			
		//now emit page content
		$titleText = $this->title();
		$inlineStyle = $this->inlineStyle();
		
		$this->emitHeaders($titleText, $inlineStyle);
		
		echo "<body>\n";
		
		$this->generateBodyContents();
		
		echo "</body>\n";
		echo "</html>\n";
	
	}
	
	
	protected function generateBodyContents()
	{
		echo <<<EOCONTENTS
		
<h3>Create a New User Account</h3>
	<form method="post" action="SubmitAccountData.php" name="create_user_form">
		<div>
			<label>User Name:</label>
			<input type='text' name='user_name' size='30'>
		</div>
		<div>
			<label>Full Name:</label>
			<input type='text' name='full_name' size='30'>
		</div>
		<div>
			<label>Password:</label>
			<input type='password' name='password1' size='20'>
		</div>
		<div>
			<label>Password (confirm);</label>
			<input type='password' name='password2' size='20'>
		</div>
		<div>
			<label>Email Address:</label>
			<input type='text' name='email_address' size='30'>
		</div>
		<p><input type='submit' value='Create User'></p>
	</form>

EOCONTENTS;
	}
	
	
	protected function emitHeaders($titleText, $inlineStyle)
	{
		echo <<<EOHEADERS
<html>
<head>
	<title>{$titleText}</title>
	<style type='text/css' media='all'>
		body
		{
			font-family: Arial, Hervetica;	
		}
		{$inlineStyle}
	</style>
</head>

EOHEADERS;
	}
	
	protected function processIncomingFormData()
	{
		// enter user page doesn't care about form data	
	}
}

$page = new CreateAccountPage();
$page->processRequest();


?>
0

edwinhermann is right.

The end delimiter for a heredoc string must be the first thing in the line, and there can not be anything after the semi-colon, not even a white-space (tabs, spaces, etc..).

The latter is also true for the start delimiter. It must be the last thing on the line.

0

I have done the changes and get the same error.

You still have a tab trailing the semi-colon on line #29.
It needs to be removed.

0

second code runs on my ide,

<?php
class CreateAccountPage {
public function __construct() {}
public function title() { return 'Create Account'; }
public function inlineStyle() { return <<<EOSTYLE
label { margin-top:0.5em; display:block; font-family:Arial, Helvetica; font-size: 10pt; color: #444; }
EOSTYLE;
}
public function processRequest() { /* first process any incoming POST data */ if(isset($_POST) and count($_POST) != 0) { $this->processIncomingFormData(); } /*now emit page content*/
$titleText = $this->title();
$inlineStyle = $this->inlineStyle();
$this->emitHeaders($titleText, $inlineStyle);
echo "<body>\n";
$this->generateBodyContents();
echo "</body>\n";
echo "</html>\n"; }
protected function generateBodyContents() { echo <<<EOCONTENTS
<h3>Create a New User Account</h3><form method="post" action="SubmitAccountData.php" name="create_user_form"><div><label>User Name:</label><input type='text' name='user_name' size='30'></div><div><label>Full Name:</label><input type='text' name='full_name' size='30'></div><div><label>Password:</label><input type='password' name='password1' size='20'></div><div><label>Password (confirm);</label><input type='password' name='password2' size='20'></div><div><label>Email Address:</label><input type='text' name='email_address' size='30'></div><p><input type='submit' value='Create User'></p></form>
EOCONTENTS;
}
protected function emitHeaders($titleText, $inlineStyle) { echo <<<EOHEADERS
<html><head><title>{$titleText}</title><style type='text/css' media='all'>body { font-family: Arial, Hervetica;	}{$inlineStyle}</style></head>
EOHEADERS;
}
protected function processIncomingFormData() { /* enter user page doesn't care about form data*/	} }
$page = new CreateAccountPage();
$page->processRequest(); ?>

packs down well
<label> tags have only real value for buttons, radio buttons, to make titles clickable, in this context they are unneccessary

Edited by almostbob: n/a

0

Thank you for all you help.

I removed all the character after the heredoc and it worked. Thanks for all you help.

Cheers

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.