sub open_dbi { # Declare and initialize variables my $host = "192.168.1.3"; my $db = "d60380940"; # NEEDS QUOTES my $db_user = "root"; # NEEDS QUOTES my $db_password = "root"; # NEEDS QUOTES # Connect to the requested server # MySQL example my $dbh = DBI->connect ("dbi:mysql:$db:$host", $db_user, $db_password, { RaiseError => 1, # When expecting problems, ENABLE! PrintError => 1, # When expecting problems, ENABLE! ShowErrorStatement => 1, # When expecting problems, ENABLE! FetchHashKeyName => "NAME_lc", # Always be predictable in key names }) or err_trap ("Cannot connect to the database"); # ODBC example semi-colon, not colon ---. ,------- Needs Host= prefix my $dbh = DBI->connect ("dbi:ODBC:DSN=d60380940;Host=192.168.1.3", undef, undef, { RaiseError => 1, # When expecting problems, ENABLE! PrintError => 1, # When expecting problems, ENABLE! ShowErrorStatement => 1, # When expecting problems, ENABLE! FetchHashKeyName => "NAME_lc", # Always be predictable in key names }) or err_trap ("Cannot connect to the database"); return $dbh; }