DataSpy Posted September 26, 2006 Share Posted September 26, 2006 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"> <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"> <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"> <input type="reset" value="Clear"> </form> </p> <?php } ?>[/code] Link to comment https://forums.phpfreaks.com/topic/22136-help-with-parse-error-parse-error-unexpected/ Share on other sites More sharing options...
thepip3r Posted September 26, 2006 Share Posted September 26, 2006 } } else { Link to comment https://forums.phpfreaks.com/topic/22136-help-with-parse-error-parse-error-unexpected/#findComment-99104 Share on other sites More sharing options...
DataSpy Posted September 26, 2006 Author Share Posted September 26, 2006 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:( Link to comment https://forums.phpfreaks.com/topic/22136-help-with-parse-error-parse-error-unexpected/#findComment-99140 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.