9 messages in com.mysql.lists.perlRe: Mysql-PerlDBI| From | Sent On | Attachments |
|---|---|---|
| Gabriele Wieczorek | 26 Jun 2001 11:34 | |
| Daniel J McDonald | 27 Jun 2001 13:47 | |
| David Block | 27 Jun 2001 15:26 | |
| Todd Finney | 27 Jun 2001 15:36 | |
| Todd Finney | 27 Jun 2001 17:49 | |
| Sherzod Ruzmetov | 27 Jun 2001 18:03 | |
| Paul A. Rubin | 29 Jun 2001 13:39 | |
| Todd Finney | 29 Jun 2001 14:19 | |
| Daniel Chester | 15 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
*************************************************************************** Paul A. Rubin Phone: (517) 432-3509 Department of Management Fax: (517) 432-1111 The Eli Broad Graduate School of Management E-mail: rub...@msu.edu Michigan State University http://www.msu.edu/~rubin/ East Lansing, MI 48824-1122 (USA) *************************************************************************** Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. J. W. v. GOETHE




