0
$qry = "SELECT user, TIME_FORMAT(last_login_time, '%H:%i') FROM login_attempts WHERE user = '".$username."'";
$result = mysql_query($qry,$this->connection);
if(!$result || mysql_num_rows($result) <= 0){
    mysql_query ("INSERT INTO login_attempts(userid, user, attempts, last_login_time) VALUES('', '$username', '{$_SESSION['count']}', '{$_SESSION['login_time']}')");           
}
else{                   
    $row = mysql_fetch_assoc($result);
    $_SESSION['login_time'] = $row["last_login_time"];
    mysql_query ("UPDATE login_attempts SET attempts = '" .$_SESSION['count']."' WHERE user = '".$username."'");            
}

在上面的代码中,我将我的$_SESSION['login_time']值存储login_attempts在列名为“last_login_time”的“”表中。

现在我需要获取该值并将其存储回$_SESSION['login_time']数组中,以便了解用户上次尝试输入的时间。我该如何获取这个值???

列的数据类型'last_login_time''timestamp'.

4

1 回答 1

1

您需要为您的TIME_FORMAT列加上别名才能引用它。

SELECT user, TIME_FORMAT(last_login_time, '%H:%i') AS last_login_time ...

另外,为什么不UPDATE尝试登录SET attempts = attempts + 1

于 2013-03-22T15:47:07.447 回答