Just some side-commands.
kejohm didn't say so, but he also dropped the double quotes around single scalar variables. They here only function as forced stringification of the two variables for user/password, wich disables undef (which is valid). I did include hist quotation fixes below. The optional arguments after the driver prefix (dbi:ODBC:) are seperated by semi-colons, not colons. User and password are not optional.
The DSN for ODBC is kinda special, please use 'perldoc DBD::ODBC::FAQ' to read all about it.
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_passw
+ord, {
RaiseError => 1, # When expecting problems, EN
+ABLE!
PrintError => 1, # When expecting problems, EN
+ABLE!
ShowErrorStatement => 1, # When expecting problems, EN
+ABLE!
FetchHashKeyName => "NAME_lc", # Always be predictable in ke
+y 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, EN
+ABLE!
PrintError => 1, # When expecting problems, EN
+ABLE!
ShowErrorStatement => 1, # When expecting problems, EN
+ABLE!
FetchHashKeyName => "NAME_lc", # Always be predictable in ke
+y names
}) or err_trap ("Cannot connect to the database");
return $dbh;
}
Enjoy, Have FUN! H.Merijn
|