CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI:
Compile error

 



Fritter
New User

Mar 5, 2009, 11:41 AM

Post #1 of 3 (3524 views)
Compile error Can't Post

Hi I'm new to perl and I wrote a script to connect to a mysql database i have but my problem is whenever i go to run it i get this error

Can't locate DBI.pm in @INC (@INC contains: /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/perl5/site_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl .) at connection.pl line 3.
BEGIN failed--compilation aborted at connection.pl line 3.


I have installed DBI on the SunOS 5.10 server which is running perl, v5.8.4 built for sun4-solaris-64int. Can somebody please help me or point me in the right direction? Thanks!


Code
 #!/usr/bin/perl 
print "Content-type: text/html nn";
use DBI; # Connect To Database
$database = "XXX";
$username = "XXX";
$password = "XXX";
$hostname = "localhost";
$db = DBI->connect("DBI:mysql:$database:$hostname", $username, $password);



1arryb
User

Mar 6, 2009, 9:13 AM

Post #2 of 3 (3518 views)
Re: [Fritter] Compile error [In reply to] Can't Post

Hi Fritter,

Well, you have a problem with your perl installation. This problem should compile as written.

One thing I noticed is that most L/Unix systems put perl in /usr/lib/perl5. You may have put DBI there by mistake. How did you install DBI?

Also, once you get your DBI (and you will also need DBD::mysql) installation straightened out, the dsn in your connect statement is wrong. It should be:

Code
$db = DBI->connect("DBI:mysql:database=$database;host=$hostname", $username, $password);


Cheers,

Larry


FishMonger
Veteran / Moderator

Mar 6, 2009, 11:01 AM

Post #3 of 3 (3515 views)
Re: [1arryb] Compile error [In reply to] Can't Post

Larry,

Both forms of the connect statement are valid. In fact, I never use the more verbose syntax.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives