It's way easier than that:
<?php
$res = mysql_query("select * from sometable");
$row = mysql_fetch_assoc($res);
print implode(":",array_keys($row));
?>
Plus this same method will work with any generic xxx_query type interface, so it's easier to port from MySQL to ORacle, to PostgreSQL, to firebird, to SAPdb, to MAX DB, to db2, to ODBC, etc...