Heya all,
This has been frustrating me all morning... I'm trying to grab the X most recent links (wow, like that's never been done before!) but want to pass the number of links to return from the template. I have:
my ($output,$sth,$link);
my $limit = shift;
my $search_db = $DB->table('Links');
$search_db->select_options ("ORDER BY Add_Date DESC","LIMIT $limit");
$sth = $search_db->select ( { isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 50) {
$link->{Title} = substr($link->{Title}, 0, 50) . '...';
}
$output .= Links::SiteHTML::display ('link_new_list', $link);
}
return $output;
}
I call it with: <%globalname('X')%> and I get: Can't call method "fetchrow_hashref" on an undefined value at (eval 1012) line 7.
If I hard-code $limit in the global it works fine. What am I missing?
Safe swoops
Sangiro
This has been frustrating me all morning... I'm trying to grab the X most recent links (wow, like that's never been done before!) but want to pass the number of links to return from the template. I have:
Code:
sub { my ($output,$sth,$link);
my $limit = shift;
my $search_db = $DB->table('Links');
$search_db->select_options ("ORDER BY Add_Date DESC","LIMIT $limit");
$sth = $search_db->select ( { isValidated => 'Yes' });
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 50) {
$link->{Title} = substr($link->{Title}, 0, 50) . '...';
}
$output .= Links::SiteHTML::display ('link_new_list', $link);
}
return $output;
}
I call it with: <%globalname('X')%> and I get: Can't call method "fetchrow_hashref" on an undefined value at (eval 1012) line 7.
If I hard-code $limit in the global it works fine. What am I missing?
Safe swoops
Sangiro