你好我有一个投票系统,有许多步骤使用会话。
当我们点击会话ID“2”时,我执行以下操作:
if ($_SESSION['vote_id'] == 1)
{
$_SESSION['vote_id'] = 2;
$vote->generate_Auth($_SERVER['REMOTE_ADDR']);
try
{
$_SESSION['auth'] = $vote->getAuth($_SERVER['REMOTE_ADDR']);
}
catch (exception $e)
{
echo $e->getMessage();
}
}
这些是我在这个动作中使用的功能:
Generate_auth:
public function generate_Auth($ip)
{
$this->gen_auth = self::pre_auth(substr(hash('SHA512', $ip), 0, 6));
$this->auth = substr(hash('SHA512', $this->gen_auth), 0, 6);
$this->quickfind = substr(str_shuffle(self::generate_quick_find_code()), 0, 21);
$this->generated_auth = $this->auth;
$this->generated_quickfind = $this->quickfind;
$this->insert = $this->pdo->prepare
("
INSERT INTO auths
(auth_code, sites_voted, voter_ip, date, time, quickfind_code)
VALUES
(:code, :sites, :ip, CURDATE(), CURTIME(), :find)
");
$this->insert->execute(array
(
":code" => $this->generated_auth,
":sites" => '1',
"ip" => $ip,
"find" => $this->generated_quickfind
));
}
获取身份验证:
public function getAuth($ip)
{
$this->get = $this->pdo->prepare("SELECT * FROM auths WHERE voter_ip = :ip LIMIT 1");
$this->get->execute(array( ":ip" => $ip));
if ($this->get->rowCount())
{
return $this->get;
}
else
{
throw new exception ("An error has occurred!");
}
}
pre_auth static:
public static function pre_auth($salt)
{
$auth = substr(hash('SHA512', $salt), 0, 6);
return $auth;
}
表演时,它给了我这个错误:
致命错误:在第0行的“未知”中没有堆栈帧的情况下抛出异常
在我生命中,我从来没有经历过这个错误,我已经读到了这个但是没有得到太多。
有人可以解释一下吗?有什么问题?