in reply to weird CGI problem

you have a spell error in line 25 as the error says:
$dbh->diconnect; should be $dbh->disconnect; I guess?

Have a nice day
All decision is left to your taste
Update:
Due to the occured error your script doesn't finish, so thats the reason that CGI.pm is being blocked from ending the task in writing the closing tags to STDOUT. A dead chicken might keep running, an ended script not. ;-)
Update_2:
And of course the theguvnor is correct as you had a warning and the script completes. I just didn't read further than teh cause of your error warning. :-)