slj90 Posted August 26, 2014 Share Posted August 26, 2014 This works... $result = mysql_query("SELECT * FROM login_attempts"); while($row = mysql_fetch_array($result)) { $diff = strtotime($row['login_date'])-time(); if ($diff > -300){ $count = $count + 1; } if ($count > 4) { $result = "locked"; } } This returns Resource ID 5... $result = mysql_query("SELECT * FROM login_attempts WHERE login_username='$username'"); while($row = mysql_fetch_array($result)) { $diff = strtotime($row['login_date'])-time(); if ($diff > -300){ $count = $count + 1; } if ($count > 4) { $result = "locked"; } } What's the problem?Many thanks, Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted August 26, 2014 Solution Share Posted August 26, 2014 At a guess, in the first one the count exceeds 4 so $result gets overwritten with "locked". In the second the count doesn't exceed 4 so $result retains the query resource id value it received when you executed the query. Don't reuse the $result variable. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.