Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^2: (mysql) failing to locate object method

by sriraj (Initiate)
on Aug 03, 2004 at 11:26 UTC ( #379582=note: print w/replies, xml ) Need Help??

in reply to Re: (mysql) failing to locate object method
in thread (mysql) failing to locate object method

hi Gilimanjaro

after doing modifications said by u only one error i am getting, the coding is as follows :==>

use strict; use warnings; use DBI; # Here's how to include the DBI module my $dbh; my $db = 'myfirstdatabase'; my $db_user = 'RAM'; my $db_password = ''; # Connect to the requested server $dbh = DBI->connect("dbi:mysql:$db","$db_user", "$db_password",{Rai +seError => 0, PrintError => 0} ) or err_trap("Cannot connect to the d +atabase"); my $sql; my $sth; my $td; $sql = "SELECT max(unxtmstmp) FROM logfl"; $sth=$dbh->prepare($sql) or die "preparing: ",$dbh->errstr; $sth->execute or die "executing: ", $dbh->errstr; $td = $sth->fetchrow_array; print "$td";


The error which i am getting when i run the above program is

C:\ram>perl Can't locate object method "connect" via package "DBI" (perhaps you fo +rgot to load "DBI"?) at line 14. C:\ram>

the line no. 14 is

$dbh = DBI->connect("dbi:mysql:$db","$db_user", "$db_password",{RaiseError => 0, PrintError => 0} ) or err_trap("Cannot connect to the database");

Edited 3 Aug 2004, by footpad: Converted <br> tags to <P> tags and added <code> tags.

Replies are listed 'Best First'.
Re^3: (mysql) failing to locate object method
by Gilimanjaro (Hermit) on Aug 03, 2004 at 11:54 UTC
    This almost certainly means something is not right with your DBI installation... Try adding
    print "$_\n" for grep /^[a-z]/, keys %DBI::;
    after your 'use DBI;'. This single line will show you all symbols (including methods) in your DBI package after you've used it. If this list contains 'connect' then there's something wrong with your perl. If it doesn't, then something is wrong with your DBI. You could try reinstalling your DBI package maybe...
      hi Gilimanjaro

      thank u very much for giving the immediate response i tried to

      run the program as per ur instructions and i didnt get any output

      This is the program


      use strict;

      use DBI;

      print "$_\n" for grep /^a-z/, keys %DBI::;

      output of the program is




      can i know what could be the error, if it is dbi installing problem

      how can i uninstall the dbi package
        This means DBI is not loaded properly, so it's probably not installed properly. I don't know much about ppm, but what I can find online seems to indicate you need to:
        ppm remove DBI ppm install DBI
        I hope it helps....

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://379582]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2023-09-21 11:48 GMT
Find Nodes?
    Voting Booth?

    No recent polls found