in reply to how to put this db connection code into a function
and i don't know how to tell if the return type is a string or a connection object. I borrowed the typeof function from another language
ref is Perl's 'typeof'.