Name

mysql_num_fields —

Synopsis

unsigned int mysql_num_fields(MYSQL_RES *result)

Returns the number of fields contained in each row of the given result set. This is different from the mysql_field_count function, in that it operates on an actual result set, which is known to contain data, whereas mysql_field_count checks the last executed query (usually to determine if an error occurred).

Example

/* 'results' is a MYSQL_RES result set structure */
num_fields = mysql_num_fields(results);
printf("There are %d fields in each row\n", num_fields);

Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.