Jump to content

[SOLVED] query not returning the correct value


shadiadiph

Recommended Posts

I have a login check to see how many time the user has logged in incorrectly at the moment it keeps returning the value of 1 even though loginfailed row says 4

any ideas where I am going wrong?

 

$checklogin = "select loginfailed from tblclientdetails where username='$username'";
$temps	= $DB_site->query($checklogin);
$failed	= $DB_site->num_rows($temps);

print $failed;

the loginfailed  field in your table includes the number of how many time their login has failed.

 

When you try num_rows,  num_row counts how many ROWS your sql query has returned.  By your code mysql is returning  1 ROW, and that ROW contain the number. So no matter what number is your failed attemps, the result is 1 ROW :)

 

You have to FETCH your results, not count how many ROW it has.

 

something like :

 

$failed  = mysql_fetch_row($temps);

 

Your desired number will be $failed[0] ;

use :

 

print $failed[0];

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.