# perl DBI and MySQL: execute method

## fifthcent

I'm playing around with databasing and perl and whatnot, trying to figure out how it all works, but I'm having some problems getting started. Well, here's the code:

```
#!/usr/bin/perl -w

use DBI;

my $data_source = "DBI:mysql:test";

my $dbh = DBI->connect($data_source,"root","censored");

my $sth = $dbh->prepare("SELECT * FROM pet");

my $rv = $dbh->execute();

my @ary = $sth->fetchrow_array;

print @ary;

print "\n";

```

But I get the following error:

```
Can't locate object method "execute" via package "DBI::db" (perhaps you forgot to load "DBI::db"?) at testdbi.pl line 10.
```

Any thoughts anyone?

----------

## rac

Change:

```
my $rv = $dbh->execute();
```

to

```
my $rv = $sth->execute();
```

----------

## fifthcent

That did it. Thanks   :Smile: 

----------

