$query = "SELECT count(*) FROM users WHERE user = $user AND password = $password";
$result = mysql_query($query, $link) or die(mysql_error());
list($num)=mysql_fetch_row($result);
echo $num;
2Nay
This way is even more advisable as it reduces traffic between web-server and mysql database and works pretty well if you need to know only the count of users with particular name-password pair.
$query = "SELECT count(user) FROM users WHERE user = ".$user." AND password = ".$password;
$result = mysql_query($query, $link) or die(mysql_error());
list($num)=mysql_fetch_row($result);
echo $num;
Count works faster if it only has to count one column... and don't put your variables between quotes.. easier to read this way..
and to be even more exact, you don't want your script to end if mysql generates an error.. so don't use the 'or die' syntax...
Hey, thanks for your help. I saw the mysql_affected_rows before but I was led to beleive it only works with inserted, updated, or deleted rows. I could have sworn that I looked at all the other mysql functions, but alas you showed me the mysql_num_rows and it is in the mysql documentation, so thanks for opening my eyes everyone.