First thing that comes to mind on the topic of the error message output to screen is your php.ini settings.
Look for "display_errors" in your php.ini
Make sure it's set to "Off"
PHP Code:
display_errors = Off
If that doesn't stop it from doing that, the script itself is probably recording the error into a variable and echoing it to the screen.
As for why it's not talking to the DB in the first place, check the log files to see what the true error message is.