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, Link to comment https://forums.phpfreaks.com/topic/290661-resource-id-5/ Share on other sites More sharing options...
Barand Posted August 26, 2014 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. Link to comment https://forums.phpfreaks.com/topic/290661-resource-id-5/#findComment-1489005 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.