None of the examples given worked for me, maybe I have an older OS?
Anyway, I did get it to work using PHP, and the code is below for anyone looking to retrieve column names via php with os/400...
Code:
//SQL quyery
$Query = "SELECT * from iesfile.drivers";
//execute query
$queryexe = odbc_do($connectionstring, $Query);
//query database
while(odbc_fetch_row($queryexe))
{
//collect results
$numfields = odbc_num_fields($queryexe);
for($i = 1;$i <= odbc_num_fields($queryexe);$i++)
{
$odbc['rows']['fieldnames'][$i] = odbc_field_name($queryexe,$i);
$odbc['rows']['fieldtypes'][$i] = odbc_field_type($queryexe,$i);
$odbc['rows']['fieldlengths'][$i] = odbc_field_len($queryexe,$i);
}
unset($i);
}