on-internet
← Community

Can't call method "disconnect" without a package

Stack Overflow ·

I wrote a Perl module: package sql; use strict; use XML::Simple; use DBI; use DBD::mysql; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(DBImport DataFill); our @EXPORT = qw(DBImport DataFill); our $dbh; sub DBConnect() { my $platform = "mysql"; my $database = "databasename"; my $host = "localhost"; my $user = "user"; my $pw = "password"; my $dsn = "dbi:mysql:$database:localhost"; $dbh = DBI->connect($dsn, $user, $pw); $dbh->do('SET NAMES utf8'); return $dbh; } sub Query($) { my $sth = $dbh->prepare(shift); $sth->execute; while (my $ref = $sth->fetchrow_hashref()) { print $ref-

Comments

Sign in or sign up to comment and upvote.

No comments yet.