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	
	}

}
?>

EOSTYLE; should be at the beginning of the line, just like the other ones.

I have changed this and I get the same error. Nothing has changed.

The file is correct, as far as I can see. Hope somebody else spots your problem.

evreything seems to be fine for me too

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.

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();


?>

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.

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.

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

Thank you for all you help.

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

Cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.