mysql_field_count()
unsigned int mysql_field_count(MYSQL *mysql)
This function returns the number of columns in a results set.
You can also use it to test whether there was an error in a
SELECT query. A SELECT query
will return at least one blank field when there is an error, resulting
in a value of 0 for the function. Here is an example:
...
if(!result)
{
if(mysql_field_count(mysql) == 0)
{
printf("Error \n");
return 1;
}
}
...See the entry for the mysql_fetch_row()
function earlier in this section for another example involving this
function.