我在脚本的最顶部有全局集,但是每当我运行它时,它都会告诉我 $db 是未定义的。
global $db;
$db = '';
$db = new Database($dbname, $host, $dbusername, $dbpassword, 'utf8', true, "Database Error");
function tryLogin($username, $password)
{
$row = $db->fetch_row("SELECT id, username, password, salt, email FROM users WHERE username = ?", true, array($username));
if(genPassWithSalt($POST['password'], $row['salt']) === $row['password'])
{
return $row;
}
else
{
return false;
}
}