Forum Moderators: coopster
parse error, unexpected $ in /home/site/public/register2.php on line 107
Thing is that there is no line 107, my code ends at line 106.
Can someone help?
Thanks
Mitchell
<?php # Script 6.6 - register.php
$page_title = 'Register';
include ('header.inc');
if (isset($_POST['submit'])) {
$message = NULL;
if (empty($_POST['firstName'])) {
$fn = FALSE;
$message .= '<p>You forgot to enter your first name.</p>';
} else {
$fn = $_POST['firstName'];
}
if (empty($_POST['LastName'])) {
$ln = FALSE;
$message .= '<p>You forgot to enter your last name.</p>';
} else {
$ln = $_POST['LastName'];
if (empty($_POST['email'])) {
$e = FALSE;
$message .= '<p>You forgot to enter your email address.</p>';
} else {
$e = $_POST['email'];
if (empty($_POST['userName'])) {
$un = FALSE;
$message .= '<p>You forgot to enter your user name.</p>';
} else {
$un = $_POST['userName'];
}
if (empty($_POST['password'])) {
$pw = FALSE;
$message .= '<p>You forgot to makeup a password.</p>';
} else {
$ln = $_POST['password'];
if ($fn && $ln && $e && $un && $pw) {
require_once ('../mysql_connect.php');
$query = "INSERT INTO guestLog (firstName, LastName, email, userName, password, registration_Date) VALUES ('$fn', '$ln',
'$e', '$un', PASSWORD('$P'), NOW() )";
$result = @mysql_query ($query);
if ($result) {
echo '<p><b>You have been registered!</b></p>';
exit();
} else {
$message = '<p>You could not be registered because your friend is still a caveman and can\'t figure this stuff. Just
give him a few days to fix me.</p><p>' .mysql_error(). '</p>';
}
mysql_close();
} else {
$message .= '<p>Please try later.</p>';
}
}
if (isset($message)) {
echo '<font color="red">', $message, '</font>';
}
?>
<form action="<?php echo $_SERVER ['PHP_SELF'];?>" method="post">
<fieldset><legend>Enter your information in the form below:
</legend>
<p>First Name:
<input type="text" name="firstName" size="15" maxlength="30" value="<?php if (isset($_POST['firstName'])) echo $_POST['firstName'];?>" />
Last Name:
<input type="text" name="LastName" size="15" maxlength="30" value=""<?php if (isset($_POST['LastName'])) echo $_POST['LastName'];?>" />
</p>
<p>Email:
<input type="text" name="email" size="15" maxlength="30" value="<?php if (isset($_POST['email'])) echo $_POST['email'];?>" />
</p>
<p>User Name:
<input type="text" name="userName" size="15" maxlength="30" value="<?php if (isset($_POST['userName'])) echo $_POST['userName'];?>" />
Password:
<input type="text" name="password" size="15" maxlength="30" value="<?php if (isset($_POST['password'])) echo $_POST['password'];?>" />
</p>
</fieldset>
<div align="center"><input type="submit" name="submit" value="Register" /></div>
</form>
<?php
include ('footer.inc');
?>
This might be it, this error often points to a missing " } " somewhere and the error shows more lines that your script has for your PHP looks further down trying to get the missing item.
You are missing a whole bunch of closing " } "
(without " " )
you need an editor that hightlight bebinning and ending braces etc..
get in the habit to comment ending " } " in your scripts even if they are not 100% your own script
for ex: }// ends line 233.
Hope it helps did not test it
cheers
Still, having an error though. It's telling me to try again later, when I try to test it.
Has something to do with this:
if ($fn && $ln && $e && $un && $pw) {
require_once ('../mysql_connect.php');
$query = "INSERT INTO guestLog (firstName, LastName, email, userName, password, registration_Date) VALUES ('$fn', '$ln',
'$e', '$un', PASSWORD('$P'), NOW() )";
$result = @mysql_query ($query);
if ($result) {
echo '<p><b>You have been registered!</b></p>';
exit();
} else {
$message = '<p>You could not be registered because your friend is still a caveman and can\'t figure this stuff. Just
give him a few days to fix me.</p><p>' .mysql_error(). '</p>';
}
mysql_close();
} else {
$message .= '<p>Please try later.</p>';
}
}
Next just before it reads
if ($fn && $ln && $e && $un && $pw) {
try to echo each value
by:
echo"fn.$fn";
I have added before the variable its name so you will know which one is which
of course do it for all of those values
next I will delete completely the
line: if ($fn && $ln && $e && $un && $pw) {
and its beginning and ending braket
then execute the script and check your database to see if any value was added
Next: I will strip the script of most of its functions and will simply try to insert anything in your db
by the way explain us what is "try later" concept?
Parse error: parse error, unexpected T_ECHO in /home/mysql_connect.php on line 31
but no matter where I look - even line 31 - I can't seem to find what this means.
Please look for this next topic, I really need all the help I can get.
Thanks
Mitchell
if (empty($_POST['password'])) {
$pw = FALSE;
$message .= '<p>You forgot to makeup a password.</p>';
} else {
$ln = $_POST['password']; Apart from the missing end bracket this should have $pw = $_POST['password'] and not $ln
also, further on your sql statement:
INSERT INTO guestLog (firstName, LastName, email, userName, password, registration_Date) VALUES ('$fn', '$ln',
'$e', '$un', PASSWORD('$P'), NOW() )"; should contain PASSWORD('$pw')?