Jump to content

Resource ID 5


slj90

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.