My Perl script should print the results of my query. However, at the moment I am getting an error:
Can't locate object method "fetchrow_array" via package "SELECT * FROM SERVER" (perhaps you forgot to load "SELECT * FROM SERVER"?) at updateDB.pl line 32
I assume the problem is easy to fix. But my perl / MySQL skills have many desires. My script is below:
use DBI;
use DBD::mysql;
use strict;
use warnings;
MySQL("SELECT * FROM SERVER");
sub MySQL
{
my $connection = DBI->connect("DBI:mysql:database=serverDNA;host=localhost");
my $query = $_[0];
my $statement = $connection->prepare($query);
$statement->execute();
while (my @row = $query->fetchrow_array)
{
print "@row\n";
}
}
Many thanks!
source
share