You put two functions into each other directly:
mysql_num_rows(mysql_query(...));
Technically this is possible to do (function 1 returns something that becomes the parameter of function 2), however, in case function 1 returns something that function 2 can not deal with, you get errors.
That happens in your case. Instead store the return value into a variable and do error handling your own:
$result = mysql_query(...);
if (!$result) {
throw new Exception(sprintf('Database query failed: %s', mysql_error()));
}
$num_rows = mysql_num_rows($result);
Proper error handling is crucial for solid programming, so take care about return values. When in doubt double-check for the function in question with the PHP manual which is really a great resource. See mysql_query
.