...

View Full Version : $end error



tyanque
06-07-2007, 11:06 PM
Im making a register form and all seems to be fine apart from 1 error:
Parse error: syntax error, unexpected $end in /web/sites/vhbu/0/156/51648/public/www2/test/register.php on line 71

heres my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
require_once ('./mysql/config.inc.php');
$page_title = 'Register';
if (isset($_POST['submitted'])) {
require_once ('../mysql/mysql_connect.php');
if (eregi ('^[[:alpha :]\.\' \-] {2,15}$',stripslashes(trim($_POST['first_name'])))) {
$fn = escape_data($_POST['first_name']);
} else {
$fn = FALSE;
echo '<p><font color="red" size="+1">Please enter your first name!</font></p>';
}
if (eregi ('^[[:alpha:]\.\' \-] {2,30}$' , stripslashes(trim($_POST['last_name'])))) {
$ln = escape_data($_POST['last_name']);
} else {
$ln = FALSE;
echo '<p><font color="red" size="+1">Please enter your last name!</font></p>';
}
if (eregi ('^[[:alnum:]] {4,20}$' , stripslashes(trim($_POST['password1'])))) {
if ($_POST['password'] == $_POST['password2']) {
$p = escape_data($_POST['password1']);
} else {
$p = FALSE;
echo '<p><font color="red" size="+1">Please enter a valid password!</font></p>';
}
if ($fn && $ln && $e && $p) {
$query = "SELECT user_id FROM users WHERE email='$e'";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
if (mysql_num_rows($result) == 0) {
$a = md5(uniqid(rand(), true));
$query = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA('$p'), '$fn', '$ln', '$a', NOW()";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
if (mysql_affected_rows() == 1) {
$body = "Thank you for regestering for Planet 1990's. To activate your account, please click on this link:";
$body .= "http://www2.hanwellvillage.com/activate.php?x=" . mysql_insert_id() . "&y=$a";
mail($_POST['email'], 'Registration Confirmation' , $body);
echo '<h3>Thank you for registering! A Confomation email has been sent to you address. Please click on the link in that email in order to activate your account.</h3>';
exit();
} else{
echo '<p><font color="red" size="+1">You could not register due to a system error. We apoligize for any inconvenience.</font></p>';
}
} else {
echo '<p><font color="red" size="+1">That email address has already been registered. If you have forgotten your password, use the link to habe your password sent to you.</font></p>';
}
} else {
echo '<p><font color="red" size="+1">Please try again</font></p>';
}
mysql_close();
}
?>
<h1>Register</h1>
<form action="register.php" method="post">
<fieldset>
<p><b>First Name:</b> <input type="text" name="first_name" size="30" maxlength="30" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></p>
<p><b>Last Name:</b> <input type="text" name="last_name" size="30" maxlength="30" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /></p>
<p><b>Email Address:</b> <input type="text" name="email" size="40" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email'] ?>" /></p>
<p><b>Password:</b> <input type="password" name="password1" size="25" maxlength="20" /><small>Use only letters and numbers. Must be between 4 and 20 charaters long.</small></p>
<p><b>Confirm Password:</b> <input type="password" name="password2" size="25" maxlength="20" /></p>
</fieldset>
<div align="center"><input type="submit" value="Register!" /></div>
<input type="hidden" name="submitted" value="TRUE" />
</form>
</body>
</html>

_Aerospace_Eng_
06-07-2007, 11:12 PM
I think it helps when you format your code like this

<?php
require_once ('./mysql/config.inc.php');
$page_title = 'Register';
if (isset($_POST['submitted']))
{
require_once ('../mysql/mysql_connect.php');
if (eregi ('^[[:alpha :]\.\' \-] {2,15}$',stripslashes(trim($_POST['first_name']))))
{
$fn = escape_data($_POST['first_name']);
}
else
{
$fn = FALSE;
echo '<p><font color="red" size="+1">Please enter your first name!</font></p>';
}
if (eregi ('^[[:alpha:]\.\' \-] {2,30}$' , stripslashes(trim($_POST['last_name']))))
{
$ln = escape_data($_POST['last_name']);
}
else
{
$ln = FALSE;
echo '<p><font color="red" size="+1">Please enter your last name!</font></p>';
}
if (eregi ('^[[:alnum:]] {4,20}$' , stripslashes(trim($_POST['password1']))))
{
if ($_POST['password'] == $_POST['password2'])
{
$p = escape_data($_POST['password1']);
}
else
{
$p = FALSE;
echo '<p><font color="red" size="+1">Please enter a valid password!</font></p>';
}
if ($fn && $ln && $e && $p)
{
$query = "SELECT user_id FROM users WHERE email='$e'";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
if (mysql_num_rows($result) == 0)
{
$a = md5(uniqid(rand(), true));
$query = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA('$p'), '$fn', '$ln', '$a', NOW()";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
if (mysql_affected_rows() == 1)
{
$body = "Thank you for regestering for Planet 1990's. To activate your account, please click on this link:";
$body .= "http://www2.hanwellvillage.com/activate.php?x=" . mysql_insert_id() . "&y=$a";
mail($_POST['email'], 'Registration Confirmation' , $body);
echo '<h3>Thank you for registering! A Confomation email has been sent to you address. Please click on the link in that email in order to activate your account.</h3>';
exit();
}
else
{
echo '<p><font color="red" size="+1">You could not register due to a system error. We apoligize for any inconvenience.</font></p>';
}
}
else
{
echo '<p><font color="red" size="+1">That email address has already been registered. If you have forgotten your password, use the link to habe your password sent to you.</font></p>';
}
}
else
{
echo '<p><font color="red" size="+1">Please try again</font></p>';
}
mysql_close();
}
?>
From this you see you never close this if statement

if (eregi ('^[[:alnum:]] {4,20}$' , stripslashes(trim($_POST['password1']))))

tyanque
06-07-2007, 11:17 PM
how do i close it though? nvm i think ive seen

tyanque
06-07-2007, 11:21 PM
fixed now im getting:
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /web/sites/vhbu/0/156/51648/public/www2/test/mysql/config.inc.php on line 6

on line six is

</head>

ooops sorry thts wrong didnt read error right

but here is my config.inc.php file

<?php
$live = FALSE;
$email = 'my email address';
function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars){
global $live, $email
$message = "An Error occurred in script '$e_file on line $e_line: \n<br /> $e_message\n<br />";
$message .= "Date/Time: " . date('n-j-Y H:i:s') . "\n<br />";
$message .= "<pre>" . print_r ($e_vars, 1) . "</pre>\n<br />";
if ($live) {
error_log ($message, 1, $email);
if ($e_number != E_NOTICE) {
echo '<div id="Error">A system error occurred. We apologize for the inconveince.</div><br />';
}
} else {
echo '<div id="Error">' . $message . '</div><br />';
}
}
set_error_handler ('my_error_handler');
?>

i dunno wat the error is?? Sorry im being such a noob =P

_Aerospace_Eng_
06-08-2007, 12:08 AM
Missing a ; on this line

global $live, $email
I suggest you start paying attention to what you type. These are simple errors.

tyanque
06-08-2007, 12:27 AM
is escape_data() a valid function if not what is the replacement?

_Aerospace_Eng_
06-08-2007, 06:00 AM
I'm guessing you are concerned about the info going into the database. If this is the case then use mysql_real_escape_string('somestring')

tyanque
06-08-2007, 12:19 PM
yup thts wat i was looking for thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum