shadiadiph Posted February 27, 2009 Share Posted February 27, 2009 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; Link to comment https://forums.phpfreaks.com/topic/147130-solved-query-not-returning-the-correct-value/ Share on other sites More sharing options...
asmith Posted February 27, 2009 Share Posted February 27, 2009 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]; Link to comment https://forums.phpfreaks.com/topic/147130-solved-query-not-returning-the-correct-value/#findComment-772414 Share on other sites More sharing options...
shadiadiph Posted February 27, 2009 Author Share Posted February 27, 2009 mm doesnt work am trying a few other ways but haven't found one to find the value of loginfailed Link to comment https://forums.phpfreaks.com/topic/147130-solved-query-not-returning-the-correct-value/#findComment-772425 Share on other sites More sharing options...
asmith Posted February 27, 2009 Share Posted February 27, 2009 Try this : <?php $checklogin = "select loginfailed from tblclientdetails where username='$username'"; $temps = $DB_site->query($checklogin); $failed = $DB_site->fetchrow($temps); print $failed[0]; ?> Link to comment https://forums.phpfreaks.com/topic/147130-solved-query-not-returning-the-correct-value/#findComment-772427 Share on other sites More sharing options...
shadiadiph Posted February 27, 2009 Author Share Posted February 27, 2009 returns this Fatal error: Call to undefined method DB_Sql_vb::fetchrow() in /home/asiapaci/public_html/site/secure/personal/checklogin2.php on line 75 Link to comment https://forums.phpfreaks.com/topic/147130-solved-query-not-returning-the-correct-value/#findComment-772428 Share on other sites More sharing options...
shadiadiph Posted February 27, 2009 Author Share Posted February 27, 2009 thanks this works $failed = $DB_site->fetch_array($temps); Link to comment https://forums.phpfreaks.com/topic/147130-solved-query-not-returning-the-correct-value/#findComment-772431 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.