pdenlinger Posted January 10, 2007 Share Posted January 10, 2007 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] Quote Link to comment Share on other sites More sharing options...
fert Posted January 10, 2007 Share Posted January 10, 2007 your forgeting to add prints to your code Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 10, 2007 Share Posted January 10, 2007 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. Quote Link to comment Share on other sites More sharing options...
pdenlinger Posted January 10, 2007 Author Share Posted January 10, 2007 Thank you.Can you suggest a good PHP editor which has syntax highlighting? Right now, I'm using Dreamweaver MX 2004 on WinXP.Paul Quote Link to comment Share on other sites More sharing options...
trq Posted January 10, 2007 Share Posted January 10, 2007 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. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 10, 2007 Share Posted January 10, 2007 I love Textpad - I've used it for years. Great editor. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.