9 messages in com.mysql.lists.perlRe: Mysql-PerlDBI
FromSent OnAttachments
Gabriele Wieczorek26 Jun 2001 11:34 
Daniel J McDonald27 Jun 2001 13:47 
David Block27 Jun 2001 15:26 
Todd Finney27 Jun 2001 15:36 
Todd Finney27 Jun 2001 17:49 
Sherzod Ruzmetov27 Jun 2001 18:03 
Paul A. Rubin29 Jun 2001 13:39 
Todd Finney29 Jun 2001 14:19 
Daniel Chester15 Jul 2001 00:06 
Subject:Re: Mysql-PerlDBI
From:Paul A. Rubin (rub@msu.edu)
Date:06/29/2001 01:39:26 PM
List:com.mysql.lists.perl

Gabi,

I suspect you will have gotten several responses by now, but you have a small error in your Perl syntax:

#!/usr/bin/perl use DBI; $database="Test_DB"; $driver="mysql"; $dsn="DBI:$driber:database=$database"; $dbh=DBI->connect($dsn,"root", "wushd") or die " Error connecting to database"; $dbh->do("Insert into Briefe values (....)"); $dbh->disconnect; exit;

(I assume "$driber" is really "$driver" in your actual code. That's not the error to which I refer.) What you want for $dsn is

$dsn="DBI:$driver:$database";

That will make the dsn string "DBI:mysql:Test_DB" after substitutions. As it stands, dsn takes the value "DBI:mysql:database=Test_DB", and so MySQL looks for a database literally named "database=Test_DB", to which you do not have permissions (because it does not exist). The error message could be a bit more helpful in this case, but what fun would programming be if error messages consistently pointed to the actual errors?

Hope this helps,

Paul