You could narrow down your search and speed up finding where its broke by appending
or die $db->errstr
to each DBI function call. Then you'd know where and why it didn't work. Also - you don't say where
$db came from? On the face of it it's possible you don't have a functioning db handle. I only mention this for the sake of completeness - not trying to tell you something you know :)
§
George Sherston