Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

    So, when I try to run this code in WAMP 2.2A P1 (32Bit) using PHP 5.3.8, I get the error
    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\www\register.php on line 31
    PHP:
    PHP Code:
    <?php
    require('database.php'); //Include DB connection information

    if (isset($_POST['register'])) { //Execute the following if form is  submitted
        
    $username mysql_real_escape_string($_POST['username']); //Post username from form
        
    $password mysql_real_escape_string(sha1(md5($_POST['pass']))); //Post password from form and encrypt
        
    $password_two mysql_real_escape_string(sha1(md5($_POST['pass_two']))); //Post password from form and encrypt
        
    if(empty($username) || empty($password) || empty($password_two)) { //Check for empty fields
            
    die("<strong>Error:</strong> All fields are required in order to register an account.");
        }

        if(
    strlen($username) > 25) { //Check if username exceeds limit of 25 characters
            
    die("<strong>Error:</strong> Your username may not exceed 25 characters.");
        }

        if (!
    preg_match("/[a-zA-Z0-9_-]/"$username)) { //Check for unallowed characters in username
            
    die("<strong>Error:</strong> Your username may only contain letters (a-z), numbers (0-9), underscores (_) and hypens (-).");
        }

        if (
    $password != $password_two) { //Check if passwords match
            
    die("<strong>Error:</strong> Your passwords do not match.");
        }

        
    $check mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
        
    $check2 mysql_num_rows($check);
        if (
    $check2 != 0) { //Check if account already exists witih this username
            
    die("<strong>Error:</strong> There is already an existing account with the username <strong>$username</strong>.");
        }

        
    mysql_query("INSERT INTO `users` (`username`, `password`)VALUES ('$username', '$password')") OR die(mysql_error());
        echo 
    "Account created! You may now <a href="login.php">login</a>."//LINE 31 HERE
    }else{ //If form is not submitted display the form
        
    echo<<<register
        <p style="font-size:21px;">Register</p>
        <form method="post" action="">
        Username: <input type="text" name="username"><br>
        Password: <input type="password" name="pass"><br>
        Confirm Password: <input type="password" name="pass_two"><br>
        <input type="submit" name="register" value="Register">
        </form>
    register;
    }
    ?>
    Thanks for the time! :)

  • #2
    Regular Coder
    Join Date
    Dec 2011
    Location
    NW England
    Posts
    194
    Thanks
    8
    Thanked 15 Times in 15 Posts
    Code:
     echo "Account created! You may now <a href=\"login.php\">login</a>.";

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah, thanks! /new to this
    /resolved


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •