There are several issues with that code that I'd like to critique, but first we'll deal with the problem at hand:
As the error message states, [man]mysql_num_rows/man expects parameter #1 (e.g. $query in your function call above) to be a resource (a MySQL result set resource, to be specific) yet you gave it boolean instead. Looking at $query, it was assigned the value of [man]mysql_query/man. Why didl [man]mysql_query/man return a boolean? Read the PHP manual:
PHP Manual wrote:For SELECT ... statements ..., mysql_query() returns a resource on success, or FALSE on error.
Therefore, you can conclude that the "FALSE on error" bit must have occurred. What error caused this? Well, for that, you should ask MySQL via the use of [man]mysql_error/man. For example, you could check the value of $query immediately after you call mysql_query() and, if it's boolean FALSE, output a helpful debugging error message that includes the text from [man]mysql_error/man (and perhaps the SQL query itself).