Gossamer Forum
Home : Products : DBMan : Customization :

Long Mod, Relational databases, errors, OH MY!

Quote Reply
Long Mod, Relational databases, errors, OH MY!
I have installed the Long/Short mod and tested it, worked fine. I then linked 2 databases exactly to the letter of JPDeni's relational.txt file, making a item database which users can add comments to each item, the comments being the many side in the one to many relationship. Everything seems to work fine except that when displaying items, it does not show the comments because of an error when showing the long format. THe error text is:

Error Message : fatal error: Not a CODE reference in sort at /usr/home23/eqfind/public_html/database/db.cgi line 471.

I assumed this was an invalid sort, however I did not modify any sor routines in db.cgi and the one I added, (which sorts by date as in the relational.txt), I removed and yet was unable to solve the problem. Does anyone have any idea what this error may be caused by? If you have any ideas, just tell me what info I should supply and I will. Below I will post the long display subroutine:

####################
#ADDED, RECORD LONG
#####################
sub html_record_long {
#----------------------------------------------------------------
my (%rec) = @_;

if ($db_total_hits > 1) {

# create links to previous and next records

$next_url = $ENV{'QUERY_STRING'};
$next_url =~ s/\&nh=\d+//;
$next_hit = $nh + 1;
$prev_hit = $nh - 1;

if ($prev_hit) {
$previous = qq~<a href="$db_script_url?$next_url&nh=$prev_hit"><$font>Previous</font></a>~;
}
else { $previous = " "; }

if ($next_hit <= $db_total_hits) {
$next = qq~<a href="$db_script_url?$next_url&nh=$next_hit"><$font>Next</font></a>~;
}
else { $next = " "; }

# create link back to short display
$list_url = $next_url;
$list_url =~ s/\&mh=\d+//;
$mh = $db_max_hits;
$lh = int(($nh-1)/$mh) + 1;
$list = qq~<a href="$db_script_url?$list_url&nh=$lh"><$font>Back to record list</font></a>~;

# print out the links
print qq|
<table width=100%>
<tr><td width=50%>$previous</td>
<td width=50% align=right>$next</td></tr>
<tr><td colspan=2 align=center>$list</td></tr>
<tr><td colspan=2 align=center><$font>Record $nh of $db_total_hits</font></table>
|;
}

# Below is where you define your form.

# <-- Start of record display -->

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';

print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Item Name:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Item_Name'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Type:</FONT></TD>
<TD> <$font>$rec{'Type'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Accessibility: </FONT></TD>
<TD> <$font>$rec{'Accessibility'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Location:</FONT></TD>
<TD> <$font>$rec{'Location'}</Font></TD></TR>
</TABLE>
|;
&switch_to_comments;
undef %in;
$rec{'ID'} =~ s/<.?B>//g;
$in{'ID'} = $rec{'ID'};
$in{'sb'} = 6;
$in{'so'} = 'descend';
$in{'mh'} = 100;

my ($status2,@hits2) = &query("view");

if ($status2 eq "ok") {
my ($numhits2) = ($#hits2+1) / ($#db_cols+1);
print qq|<table>|;

for (0 .. $numhits2 - 1) {
%rec2 = &array_to_hash($_, @hits2);
print qq|
<tr><td>
<a href="$db_script_url?db=comments&uid=$db_uid&ID=$rec2{'Comment_Number'}&view_records=1">$rec2{'Title'}</a>
</td></tr>
|;
}
print qq|</table>|;
}

&switch_to_eqfind;
# <-- End of record display -->

}



Subject Author Views Date
Post Long Mod, Relational databases, errors, OH MY! KyleHoward 704 Nov 6, 2000, 3:19 PM