Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 DataSpy

DataSpy
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 26 September 2006 - 05:49 PM

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:
if ($_POST['username'] != "" && 
      		        $_POST['password'] != "" && 
      		        $_POST['first_name'] != "" && 
      		        $_POST['last_name'] != "" && 
      		        $_POST['email'] != "") {

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!!!


<?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
			}
			?>


#2 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 26 September 2006 - 05:53 PM

    }




                } else {

#3 DataSpy

DataSpy
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 26 September 2006 - 06:43 PM

If I make it just } else {

Then I get the error:
Parse error: parse error, unexpected T_ELSE in C:\Program Files\xampp\htdocs\www\band\register.php on line 136

:(




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users