My guess is that there is a typo in the SQL used to create $sth. Specifically, are you sure you have a column named HeadName? If you can show us more code, we can be more helpful.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.