Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: (mysql) failing to locate object method

by Gilimanjaro (Hermit)
on Aug 03, 2004 at 11:09 UTC ( [id://379579]=note: print w/replies, xml ) Need Help??


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 timeinblt.pl Can't locate object method "connect" via package "DBI" (perhaps you fo +rgot to load "DBI"?) at timeinblt.pl 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

        ========================

        C:\ram>perl mysqltest.pl

        C:\ram>

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

        how can i uninstall the dbi package

Log In?
Username:
Password:

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

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

    No recent polls found