Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Perl Script connecting to DBD::MySql problem

by powerhouse (Friar)
on Dec 31, 2005 at 10:25 UTC ( [id://520119]=perlquestion: print w/replies, xml ) Need Help??

powerhouse has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to configure a perl script that I bought, which is connecting to a MySql database. Here is the code that it is using:
### connect to database on every entry to program use DBI; $driver = "mysql"; # Set somewhere else, just including it here $drh = DBI->install_driver( $driver ); $dbh = $drh->connect( $workspace,$userid,$password ); $rv = $drh->err; $str = $drh->errstr; if ($drh->err != 0) { $errormsg="Cannot connect to database"; &printerr; }


Here is the error I am getting:
Can't use an undefined value as a HASH reference at /usr/lib/perl5/site_perl/5.8.4/i686-linux/DBD/mysql.pm line 115.

I tried installing DBD::mysql again, but it just says it is already installed. Is this in the Perl, or is it actually perhaps a bad install of the DBD::mysql module? I run MySql on other sites on this server with no problems.

I know this is not totally perl, so I apologize, but if you know what could cause it, I would appreciate your responses.

thx,
Richard

Replies are listed 'Best First'.
Re: Perl Script connecting to DBD::MySql problem
by rnahi (Curate) on Dec 31, 2005 at 11:27 UTC

    What's the content of $workspace? It seems that your script is passing invalid data to "connect".

    You can also remove the call to "install_driver" and call DBI->connect instead.

Re: Perl Script connecting to DBD::MySql problem
by wfsp (Abbot) on Dec 31, 2005 at 11:38 UTC
    Is this line 115?
    my $drh = DBI->install_driver( $driver )
    If so try changing it to:
    my $drh = DBI->install_driver( $driver ) or die DBI->errstr;
    You may get more useful information.

    rnahi is right to note that you don't need install_driver but it may not be where your problem is.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-23 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found