STRING, expecting T
I'm new to php and I am trying to create a member system for my website. I seem to get an error on line 9 ("public function__construct(){") saying 'syntax error, unexpected T_STRING, expecting T_VARIABLE'. I would appreciate any help on why I am getting this error. Thanks.
My code:
<?php
include_once('connection.php')
class User {
private $db;
public function__construct(){
$this->db = new connection ();
$this->db = $this->db->dbConnect();
}
public function Login($name, $pass){
if (!empty($name) && !empty($pass) ) {
$st = $this->db->prepare("select * from users where name=? and pass=?");
$st->bindParam(1, $name);
$st->bindParam(2, $pass);
$st->execute();
if ($st->rowCount() == 1) {
echo "user verified access granted";
}else{
echo "Incorrect username or password";
}
}else{
echo "Please enter username and password";
}
}
}
?>
I see two possible errors :
public function __construct() ...
and next one is :
replace 1 , 2 while binding with '1' and '2'
The exact same problem faced my me. My mistake was to omit the space in function__construct(){}
between the function
keyword and the double underscore. One more thing you have to take care of regarding this is that you must attach curly braces to the function sign or ().
尝试函数_construct()而不是function_construct()
链接地址: http://www.djcxy.com/p/58068.html上一篇: VARIABLE,期待T
下一篇: STRING,期待T