Search code examples
phpparse-error

Parse error site


I have a parse error on my site, how can i fix it?

Error:

Parse error: syntax error, unexpected 'function__construct' (T_STRING), expecting variable (T_VARIABLE) in /home/retropla/domains/triangledevelopment.nl/public_html/classes/class.user.php on line 7

Class.users.php:

<?php

include('class.password.php');

class User extends Password{

private $db;

function__construct($db){
    parent::__construct();

    $this->_db = $db;
}

public function is_logged_in(){
    if(isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true){
        return true;
    }       
}

private function get_user_hash($username){  

    try {

        $stmt = $this->_db->prepare('SELECT password FROM blog_members WHERE username = :username');
        $stmt->execute(array('username' => $username));

        $row = $stmt->fetch();
        return $row['password'];

    } catch(PDOException $e) {
        echo '<p class="error">'.$e->getMessage().'</p>';
    }
}


public function login($username,$password){ 

    $hashed = $this->get_user_hash($username);

    if($this->password_verify($password,$hashed) == 1){

        $_SESSION['loggedin'] = true;
        return true;
    }       
}


public function logout(){
    session_destroy();
}

}


?>

I'm creating a website on a tutorial and its display this error.


Solution

  • function__construct($db){
    

    should be:

    public function __construct($db){
    
    • There needs to be a space between function and __construct.