#################################### ## Create database connection sub Conn_to_DB_Forums{ use DBI; $DSN = "DBI:mysql:me_forums:db.site.com"; $sqluser = "me1"; $sqlpass = "12345"; $dbh = DBI->connect($DSN,$sqluser,$sqlpass) || die "Cannot connect: $DBI::errstr\n" unless $dbh; return; } ## end of connect to DB subroutine #################################### #################################### ## Create database connection sub Conn_to_DB{ use DBI; $DSN = "DBI:mysql:me_content:db1.site.com"; $sqluser = "me2"; $sqlpass = "67890"; $dbh = DBI->connect($DSN,$sqluser,$sqlpass) || die "Cannot connect: $DBI::errstr\n" unless $dbh; return; } ## end of connect to DB subroutine #################################### #################################### ## Exec SQL command sub Do_SQL{ eval { $sth = $dbh->prepare($SQL); }; # end of eval # check for errors if($@){ $dbh->disconnect; print "Content-type: text/html\n\n"; print "An ERROR occurred! $@\n"; exit; } else { $sth->execute; } # end of if/else return ($sth); } ## End of Do_SQL subroutine ##################################### #################################### ## Exec SQL2 command sub Do_SQL2{ eval { $sth2 = $dbh->prepare($SQL2); }; # end of eval # check for errors if($@){ $dbh->disconnect; print "Content-type: text/html\n\n"; print "An ERROR occurred! $@\n"; exit; } else { $sth2->execute; } # end of if/else return ($sth2); } ## End of Do_SQL2 subroutine #####################################