in reply to (mysql) failing to locate object method

Could you post your *entire* code? The code you replies with earlier cannot be all of it; the error message includes a HTTP header, so you're probably using some other modules, one of which may be causing your DBI not to load. Also, please add use strict and use warnings to your code, and post the error messages again. They may be give a more precise indication of the problem...
  • Comment on Re: (mysql) failing to locate object method

Replies are listed 'Best First'.
Re^2: (mysql) failing to locate object method
by sriraj (Initiate) on Aug 03, 2004 at 11:26 UTC

    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.

      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