mysql_num_fields

Get number of fields in result

&mysql.alternative.note;

- `mysqli_num_fields`
- `PDOStatement::columnCount`

&reftitle.description; ``int``false```mysql_num_fields` `resource` `result`

Retrieves the number of fields from a query.

&reftitle.parameters;

&mysql.result.description;
&reftitle.returnvalues;

Returns the number of fields in the result set `resource` on success&return.falseforfailure;.

&reftitle.examples;

### A `mysql_num_fields` example

    <?php
    $result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
    if (!$result) {
        echo 'Could not run query: ' . mysql_error();
        exit;
    }

    /* returns 2 because id,email === two fields */
    echo mysql_num_fields($result);
    ?>

&reftitle.notes;

&info.deprecated.alias; `mysql_numfields`

&reftitle.seealso;

- `mysql_select_db`
- `mysql_query`
- `mysql_fetch_field`
- `mysql_num_rows`