in reply to Perl/CGI and first query

maybe the -1 is there because it did not find anything the first time, and your code says at a certain point in the sub retrieve:
return -1
and if you store that in $text and afterwards you try to print it.. you'll get troubles ;-)

so i'm guessing your db connection is not working...

--
to ask a question is a moment of shame
to remain ignorant is a lifelong shame