Jump to content

Syntax error in Script 8.9 for sticky forms


pdenlinger

Recommended Posts

I'm getting an unexpected T_STRING error (line 64) for my code for Script 8.9 of Larry Ullman's book, PHP for the WWW (Second Edition). I did a Google search on "unexpected T_STRING" and a forum posting said that this is almost always a missing semicolon. I went through my code looking for a missing semicolon or other error, but could not find it.

Can you please tell me what I'm doing wrong and see if the code runs? I have pasted the code in below.

Thank you.

Paul Denlinger
--------------------------------------------------------------------------
[code]
<?php /* Script 8.9 - register.php */
/* This page lets people register for the site (sort of). */

/* Address error handling */
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

/* Set the page title and include the header file. */
define ('TITLE', 'Register');
require ('templates/header.htm');

/* Basic HTML formatting stuff. */
print '<div id="leftcontent">
<h1>Registration Form</h1>
<p>Register so that you can take advantage of certain features like this, that, and the other thing.</p>';

/* Check if the form has been submitted. */
if ( isset ($_POST['submit'])) {

$problem = FALSE; /* No problems so far. */

/* Check for each value. */
if (empty ($_POST['username'])) {
$problem = TRUE;
print '<p>Please enter a username!</p>';
}

if (empty ($_POST['first_name'])) {
$problem = TRUE;
print '<p>Please enter your first name!</p>';


if (empty ($_POST['last_name'])) {
$problem = TRUE;
print '<p>Please enter your last name!</p>';

if (empty ($_POST['email'])) {
$problem = TRUE;
print '<p>Please enter your email address!</p>';



if (empty ($_POST['password1'])) {
$problem = TRUE;
print '<p>Please enter a password!</p>';

if ($_POST['password1'] != $_POST['password2']) {
$problem = TRUE;
print '<p>Your password did not match your confirmed password!</p>';

if (!problem) {/* If there weren't any problems... */

print '<p>You are now registered!<br />Okay, you are not really registered but...</p>';

} else { /* Forgot a field. */

print '<p>Please try again!</p>;

}

} /* End of handle form IF. */

/* Display the form. */
print '<form action="register.php" method="post"><p>';

print 'Username: <input type="text" name="username" size="20" value="' . $_POST['username'] . '" />
<br />';
Last name: <input type="text" name="last_name" size="20" value="' . $_POST['last_name'] . '" />
<br />';
Email address: <input type="text" name="username" size="20" value="' . $_POST['email'] . '" />
<br />';

print 'Password: <input type="password" name="password1" size="20" /><br />
Confirm Password: <input type="password" name="password2" size="20" /><br />
<input type="submit" name="submit" value="Register!" /></p>
</form>';

/* Complete the HTML formatting stuff. */
print '</div>';

require ('templates/footer.htm'); /* Need the footer. */
?>
[/code]
Link to comment
Share on other sites

Use CODE tags (hit the # button on the editor)

On line 58 you never closed your string.

[quote]print '<p>Please try again!</p>;
//Needs to be:
print '<p>Please try again!</p>';[/quote]

You might consider using an editor which does syntax highlighting, as that would have made that obvious, since the rest of your code would be colored funky.
Link to comment
Share on other sites

Does that book mention anything about indenting your code for readbility? It should.

[code=php:0]
print '<p>Please try again!</p>;
[/code]

needs to be....

[code=php:0]
print '<p>Please try again!</p>';
[/code]

Also note if you wrap your code in [ code ][ / code ] tags (no spaces) on the forum, you'll get color syntax highlighting.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.