Hi I am trying to connect to a mysql database using the following perl script:
#!/usr/bin/perl -w
use strict;
use DBI;
my $dbh = DBI->connect(
"dbi:mysql:dbname=MYDATABASENAME",
"MYUSERNAME",
"MYPASSWORD",
{ RaiseError => 1 },
) or die $DBI::errstr;
my $sth = $dbh->prepare( "SELECT * FROM classes" );
$sth->execute();
my ($class_id, $class_name, $class_number) = $sth->fetchrow();
print "$class_id $class_name $class_number\n";
my $fields = $sth->{NUM_OF_FIELDS};
print "We have selected $fields field(s)\n";
my $rows = $sth->rows();
print "We have selected $rows row(s)\n";
$sth->finish();
$dbh->disconnect();
Right now I am just getting a blank screen and I can't figure out why I am not at least getting an error message. I've spent over 20 hours trying to figure this out which is why I'm hoping someone can see what I'm doing wrong. Thanks in advance.
my $dbh = DBI->connect("dbi:mysql:database=$database;host=$DBhost;port=$port",$username,$password,where$DBhostmight be remote orlocalhost