hesco has asked for the wisdom of the Perl Monks concerning the following question:
My code throws these errors:
and reads like this:$dsn = DBI:mysql(RaiseError => 1):host=localhost.localdomain;database= +testdb $dbh = HASH(0x9d44a24) Can't call method "prepare" on unblessed reference at ./cache-pages.pl + line 28.
$dbh = ed_connect($conf{'dbversion'}, $conf{'dbhost'}, $conf{'dbname'} +, $conf{'dbuser'}, $conf{'dbpass'}); print "\$dbh = $dbh \n"; $sql = "SELECT summary FROM mod_article"; $sth = $dbh->prepare($sql); $sth->execute(); while ($node = $sth->fetchrow_array()) { $ed = $node; $ed =~ s/^.*(\d{5}).*$/$1/; print $ed; } exit; 1; sub ed_connect { my($db_version,$host_name,$db_name,$db_user,$db_pass)=@_; # my $dsn = "DBI:mysql:host=$host_name;database=$db_name"; my $dsn = "DBI:$db_version(RaiseError => 1):host=$host_name;databas +e=$db_name"; print "\$dsn = $dsn \n"; return (DBI->connect($dsn,$db_user,$db_pass), {PrintError => 1, RaiseError => 1}); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: monk seeking blessing?
by demerphq (Chancellor) on Jan 21, 2006 at 21:42 UTC | |
by hesco (Deacon) on Jan 21, 2006 at 22:04 UTC |