#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    15
    Rep Power
    0

    Parse error: syntax error, unexpected T_VAR, expecting T_VARIABLE in C:\wamp\www\www\


    Hi! i know there are plenty of peoples that encouter this error, and i googled a lot before coming here, but i still can't find the way . It's simple, i'm creating a register page where is included another file that is the register_class with all the function etc.. the error -> Parse error: syntax error, unexpected T_VAR, expecting T_VARIABLE in C:\wamp\www\www\classes\register_class.php on line 4
    register.php
    PHP Code:
    <?php 
    session_start
    ();

    if (isset(
    $_SESSION['uid'])) {

        echo 
    "You are already logged in ";
        echo 
    "<br /><a href='index.php?page=home'>HOME  | </a><a href='/member.php'> MEMBER</a>< br/>";
        exit();

    }

        
    $submit $_POST['submit'];
        
    $firstname $_POST['firstname'];
        
    $lastname $_POST['lastname'];
        
    $username $_POST['user'];
        
    $password1 $_POST['pass1'];
        
    $password2 $_POST['pass2'];
        
    $email1 $_POST['email1'];
        
    $email2 $_POST['email2'];
        
        require(
    "/classes/register_class.php");
        
    if (isset(
    $submit)) {
        
        
    $salt"";
        
    $salt1 "";
        
    $salt2 "";
        

        
    $check = new Register_class($firstname,$lastname,$username,$password1,$password2,$email1,$email2,$salt,$salt1,$salt2);
        
        if (
    $check->Checkempty($firstname,$lastname,$username,$password1,$password2,$email1,$email2) == TRUE){
            
            if (
    $check->Checkpassword($password1,$password2) == TRUE) {
                
                    if (
    $check->Checkemail($email1,$email2) == TRUE ) {
                        
                        
                        
                    } else {
                        
                        echo 
    "You emails must be the same"
                        
                    };
                
            } else {
                
              echo 
    "The passwords must be the same!";  
                
            };
        
        } else {
            
          echo 
    "You have not completed the form properly";
            
        };
        
    }








    ?>

    <html>
    <head>
    <title> Login | World Wild Web </title>
    <link href="/styles/register_style.css/" type="text/css" rel="stylesheet" />
    </head>
    <body>

        <div id="wrap">
        
            <h1>Login</h1>
            
                <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
                
                    <h3>First Name</h3> <input type="text" class=".inputs" name="firstname" placeholder="edoardo" /><br />
                     
                    <h3>Last Name</h3> <input type="text" class=".inputs" name="lastname" placeholder="edoardo" /><br />
            
                    <h3>Username</h3> <input type="text" class=".inputs" name="user" placeholder="edoardo" /><br />
                   
                    <h3>Password</h3> <input type="password" class=".inputes" name="pass1" placeholder="try123" /> <br />
                    
                    <h3>Repeat</h3> <input type="password" class=".inputes" name="pass2" placeholder="try123" /> <br />
                    
                    <h3>E-mail</h3> <input type="email" class=".inputs" name="email1" placeholder="edoardo" /><br />
                    
                    <h3>Repeat</h3> <input type="email" class=".inputs" name="email2" placeholder="edoardo" /><br /><br />
                    
                    <input type="submit" name="submit" value="Register!" />
                    
            
                </form>
        
        </div>

    </body>
    </html>
    and here is the class
    register_class.php
    PHP Code:

    <?php
    class Register_class {
        
        public var 
    $firstname;
        public var 
    $lastname;
        public var 
    $username;
        public var 
    $password1;
        public var 
    $password2;
        public var 
    $email1;
        public var 
    $email2;
        public var 
    $salt;
        public var 
    $salt1;
        public var 
    $salt2;
        public var 
    $chars 'ABCDEFGHIJKLMNOPQRSTUWXYZabcdefghijklmnopqrstuwxyz1234567890';
        const 
    host 'localhost';
        const 
    user 'root';
        const 
    pass '';
        const 
    db 'marina';
        public var 
    $con;
        
        function 
    __construct($firstname,$lastname,$username,$password1,$password2,$email1,$email2,$salt,$salt1,$salt2) {
            
    $this->firstname $firstname;
            
    $this->lastname $lastname;
            
    $this->username $username;
            
    $this->password1 $password1;
            
    $this->password2 $password2;
            
    $this->email1 $email1;
            
    $this->email2 $email2;
            
    $this->salt $salt;
            
    $this->salt1 $salt1;
            
    $this->salt2 $salt2;
        
        }
        
        function 
    Checkempty ($firstname,$lastname,$username,$password1,$password2,$email1,$email2) {
            
            if (
             
    strlen($this->firstname) == ||
             
    strlen($this->lastname) == ||
             
    strlen($this->username) == ||
             
    strlen($this->password1) == ||
             
    strlen($this->password2) == ||
             
    strlen($this->email1) == ||
             
    strlen($this->email2) == ||
             )
             {
                
                return 
    FALSE
                
             }else {
                
                return 
    TRUE;
                
             };
            
        }
        
        function 
    Checkpassword ($password1,$passoword2) {
            
            if (
    $this->password1 != $this->password2){
                
                return 
    FALSE;
            
            } else {
                
                return 
    TRUE;  
                
            };
            
        }
        
        function 
    Checkemail ($email1,$email2) {
            
            if (
    $this->email1 != $this->email2) {
            
                return 
    FALSE;
            
            } else {
                
                return 
    TRUE;
                
            };
            
        }
        
        function 
    Createsalt ($salt) {
            
            while (
    strlen($this->salt) < 4){
                
                
    $this->salt .= $this->chars{mt_rand(0,strlen($this->chars) - 1)}
                
            }
            
            return 
    $this->salt;
        }
        
        function 
    Hashpass ($password1,$salt1,$salt2) {
            
            
    $this->password1 sha1($this->salt1 "-" $this->password1 "-" $this->salt2;)
            return 
    $this->password1
            
        
    }
        
     
        
    }

    ?>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    73
    Rep Power
    108
    Alright, I'm going to admit, I just scanned this, but first thing to jump out at me. Take a close look at this line.

    PHP Code:
    $check = new Register_class($firstname,$lastname,$username,$password1,$password2,$email1,$email2,$salt,$salt1,$sa  lt2); 
    Edit: Closer look at "$sa lt2"....

    Don't know if that is what is causing your error or not, or if it was just a typo during transfer, but this will likely cause issues. Also, take a look at extract, and try passing arrays to your methods that use a large number of variables. Also, class variables of the same type can be all called from the same "public" declaration, just use commas after each variable. Both of these will clean up your code considerably. Hope this helps!
    Last edited by showerhead; March 31st, 2012 at 09:53 AM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,394
    Rep Power
    1688
    Probably not your error, but:

    Code:
        function Checkpassword ($password1,$passoword2) {
            
            if ($this->password1 != $this->password2){
    You have a typo with the $password2 variable name.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  6. #4
  7. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,742
    Rep Power
    9397
    Ha, I totally called it before I saw the code.

    "public var" is too much. Take out the "var".

    Comments on this post

    • showerhead agrees : Wow, can't believe I missed that. I remember seeing something off when I made my comment about the public variables, but I looked right past it

IMN logo majestic logo threadwatch logo seochat tools logo