in reply to Perl DBI problem
In addition to diotalevi's reply above I'd add the following. If you had used '$DBI::errstr' that would have given you more insight into what was going wrong. Below is a little self contained programme that includes using strict and warnings, which is generally considered "good practice" round here.
#!/usr/bin/perl -w use strict; use DBI; my $dbh = DBI->connect('DBI:mysql:genome', 'u', 'p') || die $DBI::er +rstr; my $sth = $dbh->prepare("SELECT foo FROM bar WHERE baz = 4"); $sth->execute() || die $DBI::errstr; while (my ($foo) = $sth->fetchrow()) { # Do something with $foo eg: print "foo = $foo\n"; } $sth->finish(); $dbh->disconnect() || warn $DBI::errstr;
Give that a try and see what happens, hope it helps.
barrd
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) 2Re: Perl DBI problem
by jeffa (Bishop) on Jun 14, 2003 at 13:21 UTC | |
by barrd (Canon) on Jun 14, 2003 at 14:19 UTC | |
by jeffa (Bishop) on Jun 14, 2003 at 14:40 UTC | |
by barrd (Canon) on Jun 14, 2003 at 15:00 UTC |