I'm not quite sure what is unblessed about what reference in my query below. Any ideas? -- Hugh
My code throws these errors:
$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.
and reads like this:
$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});
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.