Is there a script that we can call using SSI within any HTML page to show the last 10 posting
Dec 3, 2001, 8:14 AM
Veteran (19537 posts)
Dec 3, 2001, 8:14 AM
Post #3 of 27
Views: 15284
Code:
use strict; use GForum qw/$DB/;
my @posts;
my $db = $DB->table('Post');
$db->select_options("ORDER BY post_time DESC", "LIMIT 10");
my $sth = $db->select('post_id', 'post_subject');
while (my ($tags) = $sth->fetchrow_hashref) {
push @posts, qq|<a href="gforum.cgi?post=| . $tags->{post_id} . qq|;sb=post_latest_reply;so=ASC;forum_view=forum_view_collapsed;">| . $tags->{post_subject} . qq|</a>|;
}
return join '<br>', @posts;
I'm not in the mood to test it but hope it puts you on the right track.
Sep 2, 2002, 7:03 AM
Enthusiast (648 posts)
Sep 2, 2002, 7:03 AM
Post #8 of 27
Views: 15064
Paul,
I just tried this last 10 posting plugin with a version 1.1.7 of the forum and I get an internal server error. Does it only work with a previous version or am I doing something wrong ?
John
Significant Media
I just tried this last 10 posting plugin with a version 1.1.7 of the forum and I get an internal server error. Does it only work with a previous version or am I doing something wrong ?
John
Significant Media
Sep 2, 2002, 7:43 AM
Enthusiast (648 posts)
Sep 2, 2002, 7:43 AM
Post #10 of 27
Views: 15030
Hi Paul,
This is the error I'm getting at the moment :
Can't call method "table" on an undefined value at /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi line 12.
[Mon Sep 2 12:09:42 2002] [error] [client 195.206.XX.XX] Premature end of script headers: /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi
John
Significant Media
This is the error I'm getting at the moment :
Can't call method "table" on an undefined value at /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi line 12.
[Mon Sep 2 12:09:42 2002] [error] [client 195.206.XX.XX] Premature end of script headers: /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi
John
Significant Media
Sep 2, 2002, 7:53 AM
Enthusiast (648 posts)
Sep 2, 2002, 7:53 AM
Post #11 of 27
Views: 15008
Paul,
This was done to be used as an SSI and I suppose I can get it to work on the main index page but did you do one that can be directly inserted into the main index by pasting code like your other plugins ?
Thanks, John
Significant Media
This was done to be used as an SSI and I suppose I can get it to work on the main index page but did you do one that can be directly inserted into the main index by pasting code like your other plugins ?
Thanks, John
Significant Media
Sep 2, 2002, 9:04 AM
Enthusiast (648 posts)
Sep 2, 2002, 9:04 AM
Post #12 of 27
Views: 15023
I have re-installed it and I get an error most probably a chmod error. I chmoded the cgi script to 755 it was on 666.
I copied this out of my error log :
Can't use an undefined value as an ARRAY reference at /usr/local/etc/httpd/cgi-bin/deleted_domain/admin/Plugins/GForum/Block_User.pm line 39.
[Mon Sep 2 13:37:48 2002] [error] [client 195.206.XX.XX] file permissions deny server execution: /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi
As you can see the first one doesn't seem to be relative to the newposts.cgi but you may know what it is about ??
The when the chmod was changed I got this :
Can't call method "table" on an undefined value at /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi line 12.
[Mon Sep 2 14:01:13 2002] [error] [client 195.206.XX.XX] Premature end of script headers: /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi
In your script this is line 12 :
my $db = $DB->table('Post');
Does this give you any clues as to what may be going wrong ???
Significant Media
I copied this out of my error log :
Can't use an undefined value as an ARRAY reference at /usr/local/etc/httpd/cgi-bin/deleted_domain/admin/Plugins/GForum/Block_User.pm line 39.
[Mon Sep 2 13:37:48 2002] [error] [client 195.206.XX.XX] file permissions deny server execution: /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi
As you can see the first one doesn't seem to be relative to the newposts.cgi but you may know what it is about ??
The when the chmod was changed I got this :
Can't call method "table" on an undefined value at /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi line 12.
[Mon Sep 2 14:01:13 2002] [error] [client 195.206.XX.XX] Premature end of script headers: /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi
In your script this is line 12 :
my $db = $DB->table('Post');
Does this give you any clues as to what may be going wrong ???
Significant Media
Sep 5, 2002, 6:57 AM
Enthusiast (648 posts)
Sep 5, 2002, 6:57 AM
Post #14 of 27
Views: 14933
Paul took some of his time to help me out on this one so I'll just post what he gave me and enabled me to fix it. It will at least save him the time of writing it again. I hope this OK with him
I did this mod and it worked fine for me.
John
Significant Media

I did this mod and it worked fine for me.
John
Significant Media
Oct 4, 2002, 11:41 AM
User (479 posts)
Oct 4, 2002, 11:41 AM
Post #15 of 27
Views: 14901
$db->select_options("ORDER BY post_time DESC", "LIMIT $limit");
Should it list the last x posten messages ?
I get a listing where the post_id is mixed
2161
2165
2176
2162
2172
...
I would expect that the las post_id should be first to have the last messages listet in descending order
2175
2174
2173
2172
2171
.....
So I tried to change from post_time DESC to post_id DESC but I still get a mixed listing.
--
Michael Skaide
http://www.cycle24.de
Oct 4, 2002, 12:51 PM
User (479 posts)
Oct 4, 2002, 12:51 PM
Post #17 of 27
Views: 14879
In my case not.
When I browse the table post_id by Mysqlman the postings are listed correct,
but the script does not list the postings right.
If I saw the values of the columns post_time and post_id right, both should order
the records right.
I already runned -Reinxed- at Gforum-Admin.
--
Michael Skaide
http://www.cycle24.de
When I browse the table post_id by Mysqlman the postings are listed correct,
but the script does not list the postings right.
If I saw the values of the columns post_time and post_id right, both should order
the records right.
I already runned -Reinxed- at Gforum-Admin.
--
Michael Skaide
http://www.cycle24.de
Feb 3, 2003, 3:32 PM
Novice (5 posts)
Feb 3, 2003, 3:32 PM
Post #18 of 27
Views: 14443
Thanks for the code Paul.
I'm modifying it to restrict it to specific forums. I don't suppose the API is documented anywhere?
I tried $db->select_options("WHERE forum = 2", "ORDER BY post_time DESC", "LIMIT $g{'limit'}");
and $db->select_options("WHERE forum_id = 2", "ORDER BY post_time DESC", "LIMIT $g{'limit'}");
and $db->select_options("WHERE forum IN(1,2,3)", "ORDER BY post_time DESC", "LIMIT $g{'limit'}");
all NO Go
Obviously I'm just hacking here... How should I do this?
I'm modifying it to restrict it to specific forums. I don't suppose the API is documented anywhere?

I tried $db->select_options("WHERE forum = 2", "ORDER BY post_time DESC", "LIMIT $g{'limit'}");
and $db->select_options("WHERE forum_id = 2", "ORDER BY post_time DESC", "LIMIT $g{'limit'}");
and $db->select_options("WHERE forum IN(1,2,3)", "ORDER BY post_time DESC", "LIMIT $g{'limit'}");
all NO Go

Obviously I'm just hacking here... How should I do this?
Feb 4, 2003, 1:22 AM
Veteran / Moderator (2199 posts)
Feb 4, 2003, 1:22 AM
Post #19 of 27
Views: 14477
You can find many useful documents in the Help section of you administration panel. Go to "GT Module Documentation", and you'll find all you need. Take a look at "GT::SQL::Table", which deals with selects.
Ivan
-----
Iyengar Yoga Resources / GT Plugins
Ivan
-----
Iyengar Yoga Resources / GT Plugins
Feb 4, 2003, 1:01 PM
Novice (5 posts)
Feb 4, 2003, 1:01 PM
Post #20 of 27
Views: 14400
Thanks - that's just what I needed!
One thing it doesn't mention though is how to emulate SELECT DISTINCT I want to only list only 1 link per thread, but what's happening is the active threads are returning multiple times.
Suggestions anyone?

One thing it doesn't mention though is how to emulate SELECT DISTINCT I want to only list only 1 link per thread, but what's happening is the active threads are returning multiple times.
Suggestions anyone?
Feb 21, 2003, 9:48 AM
Novice (5 posts)
Feb 21, 2003, 9:48 AM
Post #21 of 27
Views: 14366
I ended up requesting 3 times as many posts as I needed and manually removed duplicate threads.
One other thing I can't do is mimic WHERE post_moved <> 1 The documentation mentions how to emulate less than or greater than or LIKE, but not "not equal" to. I suppose the other alternative would be to emulate WHERE post_moved = NULL , but I'm not sure how to set the value to NULL without turning it into a four letter string.
Any suggestions would be appreciated.
One other thing I can't do is mimic WHERE post_moved <> 1 The documentation mentions how to emulate less than or greater than or LIKE, but not "not equal" to. I suppose the other alternative would be to emulate WHERE post_moved = NULL , but I'm not sure how to set the value to NULL without turning it into a four letter string.
Any suggestions would be appreciated.
Feb 26, 2003, 12:59 AM
Administrator (9387 posts)
Feb 26, 2003, 12:59 AM
Post #22 of 27
Views: 14351
Hi,
See the docs on GT::SQL::Condition, it's what should be used for any advanced where clauses.
my $cond = GT::SQL::Condition->new('post_moved', '<>', 1);
$table->select($cond);
To do the select distinct, you would do:
$table->select('DISTINCT(column)', $cond);
Cheers,
Alex
--
Gossamer Threads Inc.
See the docs on GT::SQL::Condition, it's what should be used for any advanced where clauses.
my $cond = GT::SQL::Condition->new('post_moved', '<>', 1);
$table->select($cond);
To do the select distinct, you would do:
$table->select('DISTINCT(column)', $cond);
Cheers,
Alex
--
Gossamer Threads Inc.
Mar 18, 2003, 5:04 PM
Administrator (9387 posts)
Mar 18, 2003, 5:04 PM
Post #24 of 27
Views: 14289
Oops, use:
GT::SQL::Condition->new('post_moved', 'IS', \'NULL');
Cheers,
Alex
--
Gossamer Threads Inc.
GT::SQL::Condition->new('post_moved', 'IS', \'NULL');
Cheers,
Alex
--
Gossamer Threads Inc.