Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Last 5 for 2.1

Quote Reply
Last 5 for 2.1
I used the following Last-5-Records script for 2.03 , but now at 2.10 it does not longer run.
I changed the paths to the new installation, but there must be something with db-structure ?!
Maybe one expert can tell me what I need to change?



#!/usr/bin/perl

use strict;

# The full path to admin directory of linksql 2.0.3

use lib '/home/mydomain/public_html/sql/links/admin';

use Links qw/$DB $CFG/;

use CGI qw/:standard/;

&main;

sub main {

print header();

print qq~<style>

.navmain { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold;text-decoration: none; color: 006600}

.italic { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-style:italic ;text-decoration: none; color: 006600}

.normal { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal ;text-decoration: none; color: 000000}

</style>



~;

my $html=&link_validated;

print $html;

# print link_validated();

}

sub link_validated {

# The full path of the image file.

my $image = "message.gif";

my @data;

my $limit = 5;

my $colortablebody = '#FFCC33';

my $odd_row_color = '#B3B36F';

my $even_row_color = '#C8C896';

my $html = qq|<table width=\"100%\" cellspacing=\"0\">|;

my ($link_catlink,$category, $sth, @data, $clean_name, $catID, $catName, $count, $url);

#handle db

$link_catlink = $DB->table ('Links','CatLinks');

$category = $DB->table ('Category');



# count records in Links table.

$count = $link_catlink->count();

#display records number.





$link_catlink->select_options("order by ID DESC limit $limit");

my $sth = $link_catlink->select ( {isValidated=>'Yes'}, ['Title','LinkOwner','URL','Links.ID']);

my $i=0;

while (@data = $sth->fetchrow_array) {

# get category ID

my $catLinks = $link_catlink->select ( {LinkID=>$data[3]}, ['CategoryID'] );

$catID = $catLinks->fetchrow;

# get category name



my $cat_name = $category->select ({ID=>$catID},['Full_Name']);

$catName = $cat_name->fetchrow;

# set url for each Category

$clean_name = $category->as_url($catName);

$url = $CFG->{build_root_url} . "/" . $clean_name . "/" . $CFG->{build_index};

#display result.

$colortablebody = ( $i++ % 2 ) ? $odd_row_color : $even_row_color;

$html .= qq|



<tr bgcolor=$colortablebody>

<td><img src="$image">&nbsp;</td>

<td><A HREF="http://mydomain.com/sql/links/page.cgi?g=$clean_name/index.html&d=1" class="navmain">$data[3] $data[0]</a>

<br>

<span class=normal>($catName) </span></td>

</tr>|;

#print "$i $data[0]\n";

}

$html .= qq|</table>|;

return $html;

}


--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [Michael Skaide] Last 5 for 2.1 In reply to
Do you get any errors?
Quote Reply
Re: [RedRum] Last 5 for 2.1 In reply to
I took a look in the error-log

Can't call method "table" on an undefined value at /home/mydomain/public_html/cgi-bin/last5.cgi line 36.



Must be this line:

$link_catlink = $DB->table ('Links','CatLinks');



Michael




--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [Michael Skaide] Last 5 for 2.1 In reply to
Hmm thats strange. Its saying that $DB is undefind but it should be ok as you have:

use Links qw/$DB $CFG/;

use lib is definitely the correct path? I guess it must be otherwise it would tell you it couldn't find Links.pm
Quote Reply
Re: [RedRum] Last 5 for 2.1 In reply to
The path is right ...

I just needed to change from

.... /sql/links/admin';

to

.... /sql/links2/admin';

When I switch back to

.... /sql/links/admin';

it runs with the old installation

Michael

--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [Michael Skaide] Last 5 for 2.1 In reply to
Are all the paths in your include files updated??




PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Last 5 for 2.1 In reply to
Yes, they are ok.

I could change the other 2 URL┤s to whatever. They are just to display an image and link to the result.

Michael

--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [pugdog] Last 5 for 2.1 In reply to
I think I will use another solution with SSI and page.cgi
See other thread

Thank you
Michael



--
Michael Skaide

http://www.cycle24.de