Jump to content

Easy Error, But cannot figure out!


Immortal55

Recommended Posts

I keep getting this error for my script that I just finished making:

Parse error: parse error, unexpected $ in /home/theblizz/public_html/studiocommunity/registration.php on line 81

here is my script:

[code=php:0]
<?

include('header.php');

function checkEmail($email)
{
  if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) #checking to see if valid characters
  {
      return FALSE;
  }


if( (!$name) or (!$uname) or (!$pass) or (!$pass_two) or (!$email) )
{
echo('<center><h2>New User Registration</h2>
<br>
<form actoin="$php_self" method="post">
<table border="0">
<tr><td>Name:</td><td><input type="text" name="name" value="$name"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" value="$email"></td></tr>
<tr><td>Username:</td><td><input type="text" name="uname" value="$uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" value="$pass"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass_two" value="$passTwo"></td></tr>
'); }

if( (checkEmail($email) == TRUE) && ($pass == $passTwo) )
{
require_once('db_connect.php');
$conn = db_connect();
$db = mysql_select_db('theblizz_studio', $conn)
or die ('Registration failure, try again.');
$sql = 'SELECT * FROM users';
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$usertaken = $row['uname'];

if( $uname == $usertaken )
{
echo('Username is already in use, please choose another<br>
<a href="registration.php">Go Back</a>'); }
else {
$sql = 'INSERT INTO users
(name, email, uname, pass) VALUES
("$name", "$email", "$uname", "$pass")';
$result = mysql_query($sql, $conn)
or die ('Registration failure, try again.');

if ( $result )
{
echo('Thanks, $name, you are now a member of the Studio Community!');
}}}

else {
if( $pass != $passTwo )
{
echo('<font color="red">*Your passwords did not match.</font>
<br><br>
<center><h2>New User Registration</h2>
<br>
<form actoin="$php_self" method="post">
<table border="0">
<tr><td>Name:</td><td><input type="text" name="name" value="$name"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" value="$email"></td></tr>
<tr><td>Username:</td><td><input type="text" name="uname" value="$uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" value="$pass"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass_two" value="$passTwo"></td></tr>');
}
else {
echo('<font color="red">*Your E-mail address was not valid.</font>
<br><br>
<center><h2>New User Registration</h2>
<br>
<form actoin="$php_self" method="post">
<table border="0">
<tr><td>Name:</td><td><input type="text" name="name" value="$name"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" value="$email"></td></tr>
<tr><td>Username:</td><td><input type="text" name="uname" value="$uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" value="$pass"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass_two" value="$passTwo"></td></tr>');
}}
?>
[/code]
Link to comment
Share on other sites

for some reason the posts get all knocked out of whack when posting them.

Anyways, that error means that you did not close an if/else/elseif statemnet somewhere. Look through your code and see if you can find it.

Also a better way of using if/else/ifelse is like this.

[code=php:0]
if ($something == $something_else) {
    //do something
}elseif ($something == $whatever) {
    //do something else
}else{
  //do whatever
}[/code]

Hope this helps,
Tom
Link to comment
Share on other sites

I dont know if its related or not... but
[code=php:0]
function checkEmail($email)
{
  if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) #checking to see if valid characters
  {
      return FALSE;
  }
[/code]

i think you mean

[code=php:0]
function checkEmail($email)
{
  if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) #checking to see if valid characters
  {
      return FALSE;
  }
}
[/code]
Link to comment
Share on other sites

Uhhh the function wont return true no matter what in its current state....

try

function checkEmail($email)
{
  if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) #checking to see if valid characters
  {
      return FALSE;
  }
else {
return TRUE;
}
}
Link to comment
Share on other sites

Something is wrong with your eregi thing i think... I just tested it my self a little... try

[code=php:0]
function checkEmail($email)
{
  if(!eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", $email))
  {
return FALSE;
  }
else {
return TRUE;
}
}
[/code]
Link to comment
Share on other sites

Hehe sorry  I got a lil side tracked... Anyways here it is...

[code=php:0]
<?
include('header.php');
include('db_connect.php');
$conn = db_connect();
$db = mysql_select_db('dev', $conn) or die ('Database error.  Please try again later.');
function checkEmail($e)
{
  if(!eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", $e))
  {
return FALSE;
  }
else {
return TRUE;
}
}


$sub = $_POST['sub'];
if($sub) {
if($_POST['name'])
{
$name = $_POST['name'];
} else { $error .= "Please enter a user name.<BR>"; }
if($_POST['email'])
{
$email = $_POST['email'];
if(checkEmail($email) != TRUE) { $error .= "Your Email Address is not valid.<BR>"; }
} else { $error .= "Please enter an email address.<BR>"; }
if($_POST['uname'])
{
$uname = $_POST['uname'];
$q = "SELECT * from `users` WHERE `uname` = '" . $uname . "'";
@$num = mysql_num_rows($q);
if($num > 0) { $error .= "Sorry the user name you requested is not available.<BR>"; }
} else { $error .= "Please enter a username<BR>"; }
if($_POST['pass'])
{ $pass = $_POST['pass']; } else { $error .= "Please enter a password<BR>"; }
if($_POST['pass_two'])
{ $pass_two = $_POST['pass_two']; } else { if($pass) {  $error .= "You did not enter your password a second time!<BR>"; } }


if(($pass) && ($pass_two) && ($pass != $pass_two)) { $error .= "Your passwords do not match!<BR>"; }

if(!$error) {
$sql = "INSERT INTO `users` (`name`, `email`, `uname`, `pass`) VALUES ('" . $name . "', '" . $email . "', '" . $uname . "', '" . $pass . "')";
if(!mysql_query($sql, $conn)) { echo "Sorry! A database error has occured... Please try again later."; }
else { $no_display = "yes"; ?> <meta http-equiv="refresh" content="0;url=<? echo $_SERVER['HTTP_SELF'] . "?success=yes&user=" . $uname; ?>"> <? }
}
}
if($no_display != "yes")
{
?>
<center><font color="red"><? if($error) { echo "<B>One or more errors occured:</b> <BR>" . $error; }?></font>
<h2>New User Registration</h2>
<br>
<?
}


if(($_GET['success'] != "yes") && ($no_display != "yes")) { ?>
<form action="" method="post">
<table border="0">
<tr><td>Name:</td><td><input type="text" name="name" value="<?=$name;?>"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" value="<?=$email;?>"></td></tr>
<tr><td>Username:</td><td><input type="text" name="uname" value="<?=$uname;?>"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass_two""></td></tr>
<tr><td><input type="submit" name="sub" value="Submit"></td></tr>
</form>
<? }
else { echo "Thanks, " . $_GET['user'] . ", your are now a member of the Studio Community!"; }
if($conn)
{
mysql_close($conn);
}
?>
[/code]

If I were you I would limit the lengths of the names usernames emails and passwords...  Also i would store the passwords in MD5...  This script does work though :D

(working copy up at the momment at http://corbin-dev.no-ip.org/reg/)
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.