与MySQL和PHP纠缠

时间:2019-07-13 06:18:02

标签: php mysql

我对MySQL和PHP相当陌生,目前我正在尝试做的是创建一个登录系统,该系统将跟踪最近的登录以及谁在登录这些帐户。我已经设置了数据库,到目前为止一切正常,但是我无法执行查询。我以为我做错了什么。

这是查询的代码

$_SESSION['username'] = $userInfo['username'];
$_SESSION['ID'] = $userInfo['ID'];
$_SESSION['wsource'] = generateRandomString();
$addLog = $odb -> prepare("INSERT INTO `login_logs` VALUES(:username, NULL, :address, 0, 1, 90, 1565312048, 0)");
if($addLog -> execute(array(':username' => $_SESSION['username'], ':address' => getRealIpAddr()))){
    echo '<div class="alert alert-block alert-success fade in"><button type="button" class="close close-sm" data-dismiss="alert"><i class="fa fa-times"></i></button><strong>Success!</strong> You have logged in successfully. Redirecting..
    </div><meta http-equiv="refresh" content="3;url=index.php">';
}else{
    echo '<div class="alert alert-block alert-danger fade in"><button type="button" class="close close-sm" data-dismiss="alert"><i class="fa fa-times"></i></button><strong>Oops!</strong><br>Logging Error....</div>';
    return;
}

登录时,我收到“记录错误”消息。

0 个答案:

没有答案