Gossamer Forum
Home : Products : DBMan : Installation :

"Sort By" Problems

Quote Reply
"Sort By" Problems
OK, Here's the problem o' the day:

Got DBMan whistling along merrily as can be EXCEPT when I try a search sorting by the day. Then I get:
fatal error: Undefined sort subroutine "main:: numer_ascend" called at /usr/home/lci/WebServer/cgi-bin/db/db.cgi line 471.

Line 471 (and 472&3) is:
foreach $hit (sort $sort_func (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit; $last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sortedhits, @hits[$first .. $last]);

To access DB:
www.leelanau.com/calendar/calendar.html
Select: "Click for Power Search" to begin getting errors or:
http://www.leelanau.com/pages/farlane/

Quote Reply
Re: "Sort By" Problems In reply to
This is very odd! I would suggest that maybe you made a mistake in altering db.cgi, but I know you just installed it and you haven't had time to do much in the way of alteration.

You should have the following lines in your db.cgi script, almost at the end

Code:
# These are the sorting functions used in &query.
# --------------------------------------------------------
sub alpha_ascend { lc($sortby{$a}) cmp lc ($sortby{$b}) }
sub alpha_descend { lc($sortby{$b}) cmp lc ($sortby{$a}) }
sub numer_ascend { $sortby{$a} <=> $sortby{$b} }
sub numer_descend { $sortby{$b} <=> $sortby{$a} }
sub date_ascend { &date_to_unix($sortby{$a}) <=> &date_to_unix($sortby{$b}) }
sub date_descend { &date_to_unix($sortby{$b}) <=> &date_to_unix($sortby{$a}) }

Are they there?

Do you have any problems with sorting on alphabetical fields?

------------------
JPD


Quote Reply
Re: "Sort By" Problems In reply to
JPDeni,

Again, I am grateful. The code was in fact there. Upon reading it, I checked the .cfg file.

A question, do you suppose that: ' numer' is different from 'numer'?

Gargh. I don't think that I have EVER had a problem with a perl script that couldn't be traced to my own errors...

I have created a new mantra to guide me in my work with Perl: "Permissions, Punctuation, Spelling, Ommmmmmmmmm, Permissions, Punctuation, Spelling, Ommmmmmmmmm..."

------------------
farlane aka andrew mcfarlane
www.leelanau.com/pages/farlane/

Quote Reply
Re: "Sort By" Problems In reply to
LOL!!! Yep. Perl is picky about things like that. One of the most valuable things I learned a long time ago when I was programming in BASIC is that computers are stupid. They will do exactly what you tell them to do, even though it isn't what you really meant. And when they run across something they can't do, they usually tell you that the problem is something other than what it really is.

Glad you fixed it. And glad you posted the problem. I'll know what to tell someone else who comes up with a similar problem.


------------------
JPD