mysql_num_rows issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

mysql_num_rows issue

Post by itsmani1 »

Code: Select all

$query = "SELECT * FROM admin WHERE Login = '" . $_POST["fld_username"] . "' AND Pass = '" . $_POST["fld_password"] . "'"; 
 	$re = mysql_db_query($db,$query,$cid);
	$nu = mysql_num_rows($re);
when i run it on php 4.3 it gives me fowlling error:
any help plz.....
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/maairne/public_html/admin/act_login.php on line 16
-----------
Mannan
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

try

Code: Select all

$re = mysql_db_query($db,$query,$cid) or die(mysql_error());
and see what the cause is
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You might want to use http://www.php.net/mysql_real_escape to make sure MySQL is ready to handle the data...

For example, if someones posts O'Reilly, your query would break...
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

Code: Select all

$dbh=mysql_connect ("localhost", "maairne_maair", "maairne_maair") or die (mysql_error());
mysql_select_db ("maairne_maair");
is this correct? using corrent password...
Post Reply