gpt4 book ai didi

php - 意外的 T_STRING,期待 T_VARIABLE

转载 作者:行者123 更新时间:2023-12-02 17:41:23 25 4
gpt4 key购买 nike

我是 php 的新手,我正在尝试为我的网站创建一个成员(member)系统。我似乎在第 9 行(“public function__construct(){”)上收到一条错误消息,说“语法错误,意外的 T_STRING,期待 T_VARIABLE”。对于我为什么会收到此错误的任何帮助,我将不胜感激。谢谢。

我的代码:

<?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";
}
}
}

?>

最佳答案

我看到两个可能的错误:

public function __construct() ... 

下一个是:

用 '1' 和 '2' 绑定(bind)时替换 1 , 2

关于php - 意外的 T_STRING,期待 T_VARIABLE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20291183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com