LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   perl dbi module error "error at dbi:" dbi-> connect statement mysql (https://www.linuxquestions.org/questions/linux-newbie-8/perl-dbi-module-error-error-at-dbi-dbi-connect-statement-mysql-707427/)

haxpak 02-25-2009 08:17 AM

perl dbi module error "error at dbi:" dbi-> connect statement mysql
 
hello

i am trying to use perl to connect to mysql

my perl script looks like this:
Code:

#!/usr/bin/perl


use warnings;
use DBI;
use strict;

my $database = "project";
my $driver = "DBI:mysql";
my $dbh = DBI->connect($driver:$database, "root", "") or die "cant connect to mysql";

$dbh->do("insert into Cards values ('10896' , '1100')");
$dbh->disconnect;

but when i run the script i get error saying:
Quote:

syntax error at ./testdbi.pl line 10, near "$driver:"
Execution of ./testdbi.pl aborted due to compilation errors.
please help me with this one

thanks

haxpak 02-25-2009 08:22 AM

i have issued the following commands
if it is of some use?

Code:

our @ary = DBI->available_drivers;
#foreach (keys %drivers)
foreach (@ary)
{
print "$_ \n";
}

exit;

it returned
Quote:

DBM
ExampleP
File
Gofer
Proxy
Sponge
mysql
clearly dbi is installed for mysql, but why am i not able to use it

also
Code:

%drivers = DBI->installed_drivers();
returns nothing

Code:

perl -MDBI -e 'DBI->installed_versions'
at shell returned the following:

Quote:

Perl : 5.010000 (x86_64-linux-thread-multi)
OS : linux (2.6.18-92.1.18.el5)
DBI : 1.607
DBD::mysql : 4.005
DBD::Sponge : 12.010002
DBD::Proxy : install_driver(Proxy) failed: Can't locate RPC/PlClient.pm in @INC
DBD::Gofer : 0.011565
DBD::File : 0.35
DBD::ExampleP : 12.010007
DBD::DBM : 0.03
please help me


All times are GMT -5. The time now is 05:22 AM.