in reply to flushing CGI output

It would appear that you are telling the browser that you are going to be supplying a document of Content-type: text/html. Therefore, if you would like any data to appear in the browser you should print properly formated HTML.
print <<ENDOFTEXT; Content-type: text/html\n\n <HTML> <HEAD> Some DB Data </HEAD> <BODY> ......... Database results here .......
ENDOFTEXT Then don't forget to close the BODY and HTML tags at the end of the document.