"num_rows won't work because I'm trying to get the results of a single field"
And mysql_num_fields() will work?
Here's a test:
SELECT cas_pilot, mission FROM mission WHERE cas_pilot = '4' AND mission_no = '' AND plane_name = 'no_plane_haha'
Try the above query instead, and tell me your results.
mysql_num_fields() should return 2.
mysql_num_rows() should return 0, unless you have a row where cas_pilot='4', an empty mission_no and a funny plane named 'no_plane_haha'
Why?
mysql_num_fields(), as mentioned, returns the number of fields in a result set.
This is the number of fields that you wish to have selected.
Normally one would use this for say, a "SELECT * FROM" type of query, to dynamically get the number of fields.
For a "SELECT column1, column2, columnN FROM" type of query, it will return N, assuming that the query is correct.
This is independent of the number of rows returned in the query.
mysql_num_rows() returns the number of rows in the result set (i.e. returned from running the query).
The query that you are running will return [0,n] rows, where n is the number of rows in the table.
Within each row retrieved, however, is only 1 field, from the cas_pilot column.
But you know that the field must contain the value of 4, since that is one of the requirements in WHERE.
So, if there are m rows that have cas_pilot='4', then the result set will return [0,m] rows.
As such, if there is 1 row that fulfills all your requirements, you will get the answer of 1.
If there are none, you will get 0.
EDIT: typo