1 - prova ad eseguire da shell la stessa query e vedi cosa succede

2 -
codice:
$q = "SELECT * from guests order by posted desc";
if( $TotalRec > $max_entry_per_page ) {
$q .= " LIMIT {$no}, {$max_entry_per_page}";
}
$q = sqlite_unbuffered_query($db, $q);