Added check to see if $GLOBALS['dbh'] exists