Gossamer Forum
Home : Products : DBMan : Customization :

Please help! Fatal error after implementing "calc40.txt" (sorting)

Quote Reply
Please help! Fatal error after implementing "calc40.txt" (sorting)
Hi, I am trying to implement calc40.txt to my database.

When I press "List All" I get the full list (in short view). If I press a name I get the record. I can also press Back to full list in short view, next and previous.

BUT... when I press one of the col titles I get this errormessage:


Error Message : fatal error: Not a CODE reference in sort at db.cgi line 759.


db.cgi line 759 says:


Line 753: # Sort the array @hits in order if we are meant to sort.
Line 754: if (exists $in{'sb'}) { # Sort hits on $in{'sb'} field.
Line 755: my ($sort_order, $sort_func);
Line 756: $in{'so'} ? ($sort_order = $in{'so'}) : ($sort_order = "ascend");
Line 757: $sort_func = "$db_sort{$db_cols[$in{'sb'}]}_$sort_order";
Line 758:
Line 759: foreach $hit (sort $sort_func (keys %sortby)) {
Line 760: $first = ($hit * $#db_cols) + $hit; $last = ($hit * $#db_cols) + $#db_cols + $hit;
Line 761: push (@sortedhits, @hits[$first .. $last]);
Line 762: }
Line 763: @hits = @sortedhits;
Line 764: }


My files can be found at:

http://www.colombiaklubben.no/dbman_txt/db_cgi.txt
http://www.colombiaklubben.no/..._txt/default_cfg.txt
http://www.colombiaklubben.no/dbman_txt/html_pl.txt

The db is here
http://www.colombiaklubben.no/cgi-bin/dbman/db.cgi

You can log in with test:test (view)

Jan Peter
Quote Reply
Re: [JPWiese] Please help! Fatal error after implementing "calc40.txt" (sorting) In reply to
Viewing the source of your view all list it shows:

<TD><a href="http://www.colombiaklubben.no/cgi-bin/dbman/db.cgi?db=default&uid=test.1036519451362&view_records=1&ID=*&sb=#&so=ascend">Mors_etternavn</a></TD>

Notice that you haven't yet defined what the sort by field number is? &sb=#

The instructions state:

Be sure to change FieldName to the name of your field you want to display and the matching #s to the number of that field. You can add as many fields as you want, just by following the pattern above.

So you need to add the actual field number to match that setup in your .cfg file for each field you want to sort by in this section of the coding:

<TABLE><TR><TD><a href="$db_script_url?$new_url&sb=#&so=$so[#]">FieldName</a></TD>
<TD><a href="$db_script_url?$new_url&sb=#&so=$so[#]">FieldName</a></TD>
<TD><a href="$db_script_url?$new_url&sb=#&so=$so[#]">FieldName</a></TD>
<TD><a href="$db_script_url?$new_url&sb=#&so=$so[#]">FieldName</a></TD></TR>\n|;

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Please help! Fatal error after implementing "calc40.txt" (sorting) In reply to
In your answer you say that I should set the fieldnumbers sb=# In the line under I have two # in this line: sb=# and so=$so[#]

<TD><a href="$db_script_url?$new_url&sb=#&so=$so[#]">FieldName</a></TD>

In my html.pl it can look like this:

<TD><a href="$db_script_url?$new_url&sb=#&so=$so[9]">Mor</a></TD>

Here I have entered #=9 one of the places.

What is the diference between sb and so? (or what is sb and so?)
Should I have a number in both the sb=# and so=$so[#]? If so, same number?

Jan Peter
Quote Reply
Re: [JPWiese] Please help! Fatal error after implementing "calc40.txt" (sorting) In reply to
sb = 'sort by' is where you would define the field number of how you want the record viewed.

so = 'sort order' would be either ascend or descend defining the order in which the records display.

I'm not sure I understand how the code is setup to automatically determine the sort order. It seems to have been working fine when I viewed your db. But the sb is what needed to be defined. Try using the following and see if that gives the proper results:

<TD><a href="$db_script_url?$new_url&sb=9&so=$so[#]">Mors_etternavn</a></TD>
<TD><a href="$db_script_url?$new_url&sb=11&so=$so[#]">Fars_etternavn</a></TD>
<TD><a href="$db_script_url?$new_url&sb=54&so=$so[#]">Ungdom_navn</a></TD>
<TD><a href="$db_script_url?$new_url&sb=64&so=$so[#]">Kommune</a></TD></TR>
<TD><a href="$db_script_url?$new_url&sb=65&so=$so[#]">Fylke</a></TD></TR>\n|;

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/