很抱歉提出了这个菜鸟问题,但我是 php 新手,无法找到这个问题的确切答案。
所以无论如何,我想做的是创建一个 php 脚本,如果密码输入错误 3 次,该脚本会显示验证码通知。我遇到的问题是我相信的查询,我无法弄清楚直接从表中获取整数值。这是我的代码,任何答案将不胜感激:)
$get_login_attempts = "SELECT time FROM login_attempts WHERE email='".mysql_real_escape_string($username)."'";
$run_get_login_attempts = mysql_query($get_login_attempts);
if($run_get_login_attempts == 3){
$captcha = true;
require_once('recaptchalib.php');
$privatekey = "6LcmuvcSAAAAAPsEOXYm_lWWOPaQYLAyUo3HQ91Q";
$resp = recaptcha_check_answer($privatekey,
$_SERVER['REMOTE_ADDR'], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if(!$resp->is_valid)
die("The reCaptcha was not entered correctly, please try again");
最佳答案
mysql_query()
将返回一个资源。
您需要使用类似 mysql_fetch_array()
的函数或mysql_fetch_assoc()
以获得结果。
$run_get_login_attempts = mysql_query($get_login_attempts);
$row = mysql_fetch_assoc($run_get_login_attempts);
echo $row['time'];
关于php - 从php中的mysql表中选择整数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25183258/