LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-25-2009, 08:17 AM   #1
haxpak
Member
 
Registered: Jan 2009
Location: India
Distribution: fc9 x86_64
Posts: 35

Rep: Reputation: 15
Question 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
 
Old 02-25-2009, 08:22 AM   #2
haxpak
Member
 
Registered: Jan 2009
Location: India
Distribution: fc9 x86_64
Posts: 35

Original Poster
Rep: Reputation: 15
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:BM : 0.03
please help me
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
error while using perl:dbi to connect to access db2 data on mainframes ndesai Linux - General 6 06-12-2008 04:35 PM
perl:dbi on linux:error to access db2 data on mainframes ndesai Programming 2 06-06-2008 06:24 AM
Error using DBI with Perl bostonantifan Ubuntu 0 11-11-2007 01:47 PM
DBI perl "insert" problems Xris718 Programming 3 02-09-2005 03:33 PM
mysql failed: dbi error chadi Linux - General 1 10-30-2004 10:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration