1

今天我厌倦了从mysql连接到PDO。我遇到了一个问题。

require('config.php');

function GetAll($query, $params) {
    global $db;
    try {
        $sth = $db->prepare($query);
    }
    catch (PDOException $e) {

        return null;
    }
    try {
        $sth->execute($params);
    }
    catch (PDOException $e) {

        return null;
    }
    $result = $sth->fetchAll();
    return $result;
}

if ($fetch = GetAll("SELECT `loggedip` FROM `ipcheck` WHERE `loggedip`=':ipcheck'", array(":ipcheck" => $iptocheck))) {

    $resultx = $db->prepare("SELECT `failedattempts` FROM `ipcheck` WHERE `loggedip`='$iptocheck'");
    $resultx->execute();
    while ($rowx = $resultx->fetch()) {
        ;
    }
    $loginattempts_total = $rowx['failedattempts'];
    echo "$loginattempts_total";
    if ($loginattempts_total > $maxfailedattempt) {
        header(sprintf("Location: %s", $forbidden_url));
        exit;
    }
}

这是我的脚本。在 PDO 中,他的不起作用。当我的ip被禁止时不应该看到,但我看到的页面。请帮忙 ((

4

0 回答 0