mysql_fetch_lengths()
unsigned long *mysql_fetch_lengths(MYSQL *result)
This function returns the length of each column within a particular row of a results set. The values returned can vary for each row fetched, depending on the data contained in the columns. Here is an example:
...
mysql_query(mysql, "SELECT * FROM clients");
result = mysql_store_result(mysql);
row = mysql_fetch_row(result);
unsigned int num_fields = mysql_num_fields(result);
unsigned long *lengths = mysql_fetch_lengths(result);
for(i = 0; i < num_fields; i++)
{
field = mysql_fetch_field(result);
printf("%s %lu \n", field->name, lengths[i]);
}
...This example retrieves one row of the results and checks the
lengths of the fields in that row. To retrieve each field, the
SELECT statement would need to be altered and a
while statement would be wrapped around the
for statement to loop through each row.