Jump to content

help with "Parse error: parse error, unexpected '}' "


DataSpy

Recommended Posts

I got most of this code out of a book and was messing around with it, I took some validation code out of it because I want to validate using javascript instead of php.

The validation code I took out:
[code]if ($_POST['username'] != "" &&
              $_POST['password'] != "" &&
              $_POST['first_name'] != "" &&
              $_POST['last_name'] != "" &&
              $_POST['email'] != "") {[/code]

Now I get "Parse error: parse error, unexpected '}' in C:\Program Files\xampp\htdocs\www\band\register.php on line 138"

Any help would be greatly appretiated, thanx in advance!!!


[code]<?php
//<!-- checks to make sure required info is filled out -->
            if (isset($_POST['submit']) && $_POST['submit'] == "Register") {



      //<!-- this is where the validation code was -->



//<!-- checks to make sure username is unique -->
                $query = "SELECT username FROM user " . "WHERE username = '" . $_POST['username'] . "';";
            $result = mysql_query($query)
              or die(mysql_error());
            if (mysql_num_rows($result) != 0) {
        ?>
<!-- display this if username is already taken -->
  <font color="#FF0000"><b>The Username, <?php echo $_POST['username']; ?>, is already in use, please choose another!</b></font>
  <form action="register.php" method="post">
    Username: <input type="text" name="username"><br>
    Password: <input type="password" name="password" value="<?php echo $_POST['password']; ?>"><br>
    Email: <input type="text" name="email" value="<?php echo $_POST['email']; ?>"><br>
    First Name: <input type="text" name="first_name" value="<?php echo $_POST['first_name']; ?>"><br>
    Last Name: <input type="text" name="last_name" value="<?php echo $_POST['last_name']; ?>"><br>
    City: <input type="text" name="city" value="<?php echo $_POST['city']; ?>"><br>
    State: <input type="text" name="state" value="<?php echo $_POST['state']; ?>"><br>
Country: <input type="text" name="country" value="<?php echo $_POST['country']; ?>"><br>
Zip Code: <input type="text" name="zip" value="<?php echo $_POST['zip']; ?>"><br><br>
    <input type="submit" name="submit" value="Register"> &nbsp;
    <input type="reset" value="Clear">
  </form>
<!-- inserts information into database -->
<?php
    } else {
$email      = $_POST['email'];
$username  = $_POST['username'];
$password  = $_POST['password'];
$first_name = $_POST['first_name'];
$last_name  = $_POST['last_name'];
$city      = $_POST['city'];
$state      = $_POST['state'];
$zip        = $_POST['zip'];
$country    = $_POST['country'];
          $query = "INSERT INTO users SET
            email      = '$email',
            username  = '$username',
password  = '$password',
first_name = '$first_name',
last_name  = '$last_name',
city      = '$city',
state      = '$state',
zip        = '$zip',
country    = '$country'";
      $result = mysql_query($query)
            or die(mysql_error());
      $_SESSION['uname'] = $_POST['username'];
      $_SESSION['upassword'] = $_POST['password'];
          ?>
    Thank you, <?php echo $_POST['first_name'] . " " . $_POST['last_name']; ?> for registering!<br>
  <?php
        header("Refresh: 5; URL=index.php");
        echo "Your registration is complete! " . "You are being sent to the page you requested!<br>";
      echo "(If your browser doesn't support this, " . "<a href=\"index.php\">click here</a>)";
    die();
      }
    } else {
  ?>
<!-- echo this if all required info isn't filled out -->
  <font color="#FF0000"><b>The Username, Password, Email, First Name,
  and Last Name fields are required!</b></font>
  <form action="register.php" method="post">
    Username: <input type="text" name="username" value="<?php echo $_POST['username']; ?>"><br>
    Password: <input type="password" name="password" value="<?php echo $_POST['password']; ?>"><br>
    Email: <input type="text" name="email" value="<?php echo $_POST['email']; ?>"><br>
    First Name: <input type="text" name="first_name" value="<?php echo $_POST['first_name']; ?>"><br>
    Last Name: <input type="text" name="last_name" value="<?php echo $_POST['last_name']; ?>"><br>
        City: <input type="text" name="city" value="<?php echo $_POST['city']; ?>"><br>
    State: <input type="text" name="state" value="<?php echo $_POST['state']; ?>"><br>
Country: <input type="text" name="country" value="<?php echo $_POST['country']; ?>"><br>
Zip Code: <input type="text" name="zip" value="<?php echo $_POST['zip']; ?>"><br><br>
    <input type="submit" name="submit" value="Register"> &nbsp;
    <input type="reset" value="Clear">
  </form>
</p>
<?php
      }




                } else {            //<!-- <=== line 138 -->




    ?>
<!-- this is the registration form -->
  Welcome to the registration page!<br>
  The Username, Password, Email, First Name, and Last Name fields are required!
  <form action="register.php" method="post">
    Username: <input type="text" name="username"><br>
    Password: <input type="password" name="password"><br>
    Email: <input type="text" name="email"><br>
    First Name: <input type="text" name="first_name"><br>
    Last Name: <input type="text" name="last_name"><br>
    City: <input type="text" name="city"><br>
    State: <input type="text" name="state"><br>
Country: <input type="text" name="country"><br>
Zip Code: <input type="text" name="zip"><br><br>
    <input type="submit" name="submit" value="Register"> &nbsp;
    <input type="reset" value="Clear">
  </form>
</p>
<?php
}
?>[/code]
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.