You can call the mysql_fetch_lengths() function to return the lengths of the columns of the current row in a result set.
Syntax
unsigned long *
mysql_fetch_lengths(MYSQL_RES *result)
Return values
An array of unsigned integers indicating the length of every column (excluding the terminating null character) is returned, and NULL is returned if an error occurred.
Errors
mysql_fetch_lengths () is valid only for the current result set row. It returns NULL if you call it before calling mysql_fetch_row() or after retrieving all rows in the result set.
Notes
After you call this function to obtain length information, you do not need to call strlen(), which will return an error result for fields containing null characters. If a result set contains binary data, you must call this function to determine the data size. The lengths of empty columns and columns containing NULL values are 0.