Jump to content

mysql_num_rows not working properly


Gath

Recommended Posts

So, alghouth i know there are results in the db, i keep getting 0 as mysql_num_rows.

 

$check = mysql_query("SELECT login FROM db_login WHERE login=\"$email\"");
$check_rows = mysql_num_rows($check);

if ($check_rows > 0)  blablabla

 

 

The result from $check_rows is always 0. I'm lost. Any help?

Using 5.3.9 php.

Link to comment
https://forums.phpfreaks.com/topic/273837-mysql_num_rows-not-working-properly/
Share on other sites

You need to do some debugging.

 

Do you get a row back when you run the same query in MySQL editor?

 

Does this trigger an error? (Make sure display_errors is turned on in your php configuration)

$check = mysql_query("SELECT login FROM db_login WHERE login=\"$email\"") or trigger_error(mysql_error());

Another consideration:

 

Are you sure the value you *think* is in $mail actually exists in the DB? Could be that the original value and the value in $email were escaped, trimmed, etc. differently which would also explain why you get 0 results.

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.