Well, this is embarrassing ... the $META_ALBUM_SET line Nibbler mentioned I didn't really know what that did when I put it in there - it's the *only* line I didn't understand (really!) - I grabbed it from the 'lastalb' code. So I'm not surprised if it's useless or does something bad. I forgot about it until now.
If your problem is the search results with albums with 0 photos, here's a quick fix that will remove the database error and gives a result with the correct link but with bad stats & no thumbnail.
Find this block of code in function searchalbum_hijacklastalb:
$query_newpic = "SELECT *,a.title AS title,a.description as description,p.ctime as ctime FROM {$CONFIG['TABLE_ALBUMS']} as a,{$CONFIG['TABLE_PICTURES']} as p WHERE (a.aid=p.aid AND p.ctime = $maxctime)";
$result_newpic = cpg_db_query($query_newpic);
$rowset_newpic = cpg_db_fetch_rowset($result_newpic);
$rowset[$irow] = $rowset_newpic[0];
mysql_free_result($result_newpic);
and replace it with this block:
if ($maxctime) {
$query_newpic = "SELECT *,a.title AS title,a.description as description,p.ctime as ctime FROM {$CONFIG['TABLE_ALBUMS']} as a,{$CONFIG['TABLE_PICTURES']} as p WHERE (a.aid=p.aid AND p.ctime = $maxctime)";
$result_newpic = cpg_db_query($query_newpic);
$rowset_newpic = cpg_db_fetch_rowset($result_newpic);
$rowset[$irow] = $rowset_newpic[0];
mysql_free_result($result_newpic);
} else {
$cpg_nopic_data = cpg_get_system_thumb('nopic.jpg',10001);
$cpg_nopic_data['filename'] = basename($cpg_nopic_data['thumb']);
$cpg_nopic_data['filepath'] = dirname($cpg_nopic_data['thumb']).'/';
foreach ($cpg_nopic_data as $key => $value) {
$rowset[$irow][$key] = $value;
}
$rowset[$irow]['caption'] = '<img src="' . $cpg_nopic_data['thumb'] . '" ' . $cpg_nopic_data['whole'] . ' class="image" border="0" alt="" />';
// $rowset[$irow]['aid'] = $row['aid'];
// echo "<pre>"; print_r($cpg_nopic_data); echo "</pre>";
// $rowset[$irow]['title'] = $row['title'];
// $rowset[$irow]['description'] = $row['description'];
// $rowset[$irow]['category'] = $row['category'];
}
As you might be able to tell, the new code has some commented out lines which is part of my testing for the correct code that will give the correct system thumbnail for 'nopic' and the correct stats. I haven't had time to work on this since I last posted. I figured I'd post this little bit now if you want to remove the database error.