#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    I have tried to run some scrip with "use DBI;" statement. and it produces error "Can't locate DBD/MySql.pm in @INC...."
    I need it to connect to MySql.

    Could someone please tell me what files do I need and where to put them in my cgi-bin ?

    I tried downloading modules from cpan.org, but I get lost.
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    This is error which appears in telnet after running program which has "use DBI;" statement.
    I have DBI.pm in same directory as script (cgi-bin) and MySql.pm in cgi-bin/DBD/MySql.pm

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    [upitnik@mighty cgi-bin]$ perl baza.cgi
    DBD::MySql initialisation failed: Can't locate object method "driver" via package "DBD::MySql" at /usr/lib/perl5/site_perl/5.005/i386-linux/DBI.pm line 511.

    Perhaps the capitalisation of DBD 'MySql' isn't right. at baza.cgi line 7
    [upitnik@mighty cgi-bin]$
    [/code]

    [This message has been edited by Pepe (edited October 09, 2000).]
  6. #4
  7. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    As mentioned from my link, you need to have a "use lib" line in addition to your "use DBI;" line. The path of use lib needs to be full server path.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    I added that line, but nothing changed.
    Beginning of my script look like this:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    #!/usr/bin/perl

    use lib '/home/sites/site337/cgi-bin';

    use DBI;

    my $dbh = DBI->connect('DBI:MySql:upitniknet', 'upitnik', 'xxxyyy')
    or die "Couldn't connect to database: " . DBI->errstr;
    my $sth = $dbh->prepare('SELECT * FROM test WHERE lastname = ?')
    or die "Couldn't prepare statement: " . $dbh->errstr;
    [/code]

    I even tried to add:
    "use lib '/home/sites/site337/cgi-bin/DBD';"
    but it is same.

    [This message has been edited by Pepe (edited October 09, 2000).]
  10. #6
  11. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    >>Perhaps the capitalisation of DBD 'MySql' isn't right. at baza.cgi line 7

    Have you checked that?

    >>my $dbh = DBI->connect('DBI:MySql:upitniknet', 'upitnik', 'xxxyyy')

    It should be "mysql", not "MySql".
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    I thought it should be same as file name.
    It works now

    Thanks

IMN logo majestic logo threadwatch logo seochat tools logo