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

Okay. I have MySQL and Apache installed on a Gentoo box. I have a script that uses the following to insert data into a MySQL database.
my $dbh = DBI->connect("DBH:mysql:dbname=router:host=localhost","usern +ame","passwd", {'RaiseError' => 1 });
and it works just fine. I confirm the data is entered by poking around MySQL. It goes off w/o a hitch.

Now, in my cgi script that I will use to display this info, I connect with the exact same line, AND I'm connecting from the exact same machine, but I get this error in the browser.
Can't connect(DBH:mysql:dbname=router:host=localhost username passwd H +ASH(0x827b5ac)), no database driver specified and DBI_DSN env var not + set at /var/www/localhost/cgi-bin/first.pl line 10
I looked around on Google, but none of the hits I came up w/ offered a very good solution. Basically, the only thing different in the two scripts is the user running them.

Thanks.

Replies are listed 'Best First'.
Re: more MySQL fun
by borisz (Canon) on Jan 11, 2005 at 01:05 UTC
    Try:
    my $dbh = DBI->connect("DBI:mysql:database=router;host=localhost","use +rname","passwd", {'RaiseError' => 1 });
    Boris
      Yeah... how the hell did I get DBH anyway? Well, I'm getting a 500 error now, but that's a start.
Re: more MySQL fun
by runrig (Abbot) on Jan 11, 2005 at 01:02 UTC
    ...connect("DBH:mysql:dbname=....)
    DBH?? It's usually "dbi"