Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Can't locate object method...

by azool (Initiate)
on Apr 18, 2002 at 19:18 UTC ( [id://160311]=perlquestion: print w/replies, xml ) Need Help??

azool has asked for the wisdom of the Perl Monks concerning the following question:

this code:
my $dbh = DBI->connect("dbi:mysql:table","user","password", {AutoCommit => 1, RaiseError => 1}) or die die "Can\'t connect: ",$DBI::errstr;
returns:
"Can't locate object method "connect" via package "DBI" at script.pl line 3."
DBI and DBD:mysql are installed and up-to-date... I'm at a loss as to what the problem is.

Replies are listed 'Best First'.
Re: Can't locate object method...
by elbie (Curate) on Apr 18, 2002 at 19:32 UTC
    Make sure you include the DBI module. Put

    use DBI;

    at the top of your script

    elbieelbieelbie

      That was it...
      I _knew_ it was something silly like that when I couldn't
      find anyone else who'd had the problem. I just knew it
      couldn't be OS X's fault ;)
Re: Can't locate object method...
by particle (Vicar) on Apr 18, 2002 at 19:21 UTC
    s/->/::/;

    Update: now don't i feel silly... look below.

    ~Particle ;Þ

      As the first line of DBI::connect() is my $class = shift;, what do you expect your code to do?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://160311]
Approved by particle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-19 10:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found