syntax error, unexpected '{'

Discussion in 'Web Design and Development' started by JLEW700, Jul 17, 2009.

  1. JLEW700 macrumors 6502

    Joined:
    Aug 12, 2008
    #1
    Can somebody please help me find whats wrong with my code. whenever I click on register it says:
    Parse error: syntax error, unexpected '{' in /Applications/XAMPP/xamppfiles/htdocs/register.php on line 33

    Here is my code:
    Code:
    <?php
    echo "<h1>Register</h1>";
    
    $submit = $_POST['submit'];
    
    $fullname = strip_tags($_POST['fullname']);
    $username = strip_tags($_POST['username']);
    
    $password = strip_tags($_POST['password']);
    $repeatpassword = strip_tags($_POST['repeatpassword']);
    $date = date("y-m-d");
    
    
    if ($submit)
    {
    
    if ($fullname&&$username&&$password&&$repeatpassword)
    {
    
    	$password = md5($password);
    	$repeatpassword = md5($repeatpassword);
    
    	if ($password==$repeatpassword)
    	{
    	if (strlen($username)>25||strlen($fullname)>25)
    	{
    	echo "Length of username or fullname is too long.";
    
    	}
    	else
    	{
    	if (strlen($password)>25||strlen($password<6)
    	{
    	echo "Password must be between 6 and 25 characters";
    	}
    	else
    	{
    	
    	echo "success";
    
    		}
    
    	}
    
    }
    	else
    		echo "Your passwords do not match";
    
    	
    }
    else
    	echo "Please fill in <b>all</b> fields.";
    
    }
    
    ?>
    <p>
    
    <html>
    
    <form action='register.php' method='POST'>
    	<table>
    		<tr>
    			<td>
    			Your full name:
    			</td>
    			<td>
    			<input type='text' name='fullname'>
    			</td>
    		</tr>
    		<tr>
    			<td>
    			Choose a username:
    			</td>
    			<td>
    			<input type='text' name='username'>
    			</td>
    		</tr>
    		<tr>
    			<td>
    			Choose a password:
    			</td>
    			<td>
    			<input type='password' name='password'>
    			</td>
    		</tr>
    		<tr>
    			<td>
    			Repeat your password:
    			</td>
    			<td>
    			<input type='password' name='repeatpassword'>
    			</td>
    		</tr>
    	</table>
    	<p>
    	<input type='submit' name='submit' value='Register'>
    
    </form>
    
    </html>
    
     
  2. Coolnat2004 macrumors 6502

    Coolnat2004

    Joined:
    Jan 12, 2005
    #2
    Take a look at line 33 and the line right above it:
    PHP:
    if (strlen($password)>25||strlen($password<6)
        {
    You're parentheses are unbalanced. You want it to be:
    PHP:
    if ( strlen($password) > 25 || strlen($password) < )
        {
     
  3. JLEW700 thread starter macrumors 6502

    Joined:
    Aug 12, 2008
    #3
    ok, I copied the code you just gave me and it worked, but im not exactly sure whats different about it. Did you just but a bunch of spaces in?
     
  4. yg17 macrumors G5

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #4

    You were missing a closing parenthesis. The number of opening and closing parenthesis should always be equal, you had 3 opening and 2 closing.

    Look at the second strlen statement, you were missing a closing one there.
     
  5. JLEW700 thread starter macrumors 6502

    Joined:
    Aug 12, 2008
    #5
    after password and before <. got it, thanks guys
     

Share This Page