Gossamer Forum
Home : Products : DBMan : Customization :

fatal error: Undefined subroutine in sort at db.cgi line 855

Quote Reply
fatal error: Undefined subroutine in sort at db.cgi line 855
Could someone please help me find the cause of the error I describe below, and also perhaps tell me why even though I have $db_debug = 0; I still get the error displayed.

As always, many thanks for your time.
--------------------------------------

I am using a relational database.
I have two users registered.
When I:

Search by User
http://www.marscafe.com/cgi-bin/dbman/famrecipes/db.cgi?db=user&uid=mars.11647109173802&UserID=arco&view_records=View+Records

OR

List All Users
http://www.marscafe.com/cgi-bin/dbman/famrecipes/db.cgi?db=user&uid=mars.11647109173802&view_records=1&sb=2&so=ascend&UserID=*&nh=1&mh=1


I get the following error message displayed (even though I have $db_debug = 0; in both the use.cfg and item.cfg files)
- but Only when I select the earliest user registered (chronologically) in the list

CGI ERROR
==========================================
Error Message : fatal error: Undefined subroutine in sort at db.cgi line 855.



FROM db.cgi (line 855 begins with foreach $hit)
# Sort the array @hits in order if we are meant to sort.
if (exists $in{'sb'}) { # Sort hits on $in{'sb'} field.
my ($sort_order, $sort_func);
$in{'so'} ? ($sort_order = $in{'so'}) : ($sort_order = "ascend");
$sort_func = "$db_sort{$db_cols[$in{'sb'}]}_$sort_order";

foreach $hit (sort $sort_func (keys %sortby)) {
$first = ($hit * $#db_cols) + $hit; $last = ($hit * $#db_cols) + $#db_cols + $hit;
push (@sortedhits, @hits[$first .. $last]);
}
@hits = @sortedhits;
}
Quote Reply
Re: [mars2] fatal error: Undefined subroutine in sort at db.cgi line 855 In reply to
You might try adding a "so" or "sb" variable to your form or links. It's looking for one of those.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] fatal error: Undefined subroutine in sort at db.cgi line 855 In reply to
JPD,
Once again, many thanks, problem solved.

If you have time for another small issue:
When I delete a record from the "many" database (in this case a recipe), instead of, let us say
The following records were deleted from the database: 'Pistachio Cake'.

I get the record number, which is not very useful to a regular user
The following records were deleted from the database: '9'.

Could you point me to where I need to look so that I can use the recipe name field instead of the record number for the splash-back screen?

Regards again-
Chef Mars

Quote Reply
Re: [mars2] fatal error: Undefined subroutine in sort at db.cgi line 855 In reply to
Now you're gettin' tricky. ;)

This would have to be in db.cgi, delete_records.

Try changing

Code:

$delete_list{$data[$db_key_pos]} ? # if this id is one we want to delete
($delete_list{$data[$db_key_pos]} = 0) : # then mark it deleted and don't print it to the new database.
($output .= $line . "\n"); # otherwise print it.



to

Code:

if ($delete_list{$data[$db_key_pos]} ) { # if this id is one we want to delete
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
$succstr .= $data[position of field you want to display] , ", ";
}
else {
$output .= $line . "\n"; # otherwise print it.
}


and change

Code:

foreach $key (keys %delete_list) {
$delete_list{$key} ? # Check to see if any items weren't deleted
($errstr .= "$key,") : # that should have been.
($succstr .= "$key,"); # For logging, we'll remember the one's we deleted.
}



to

Code:

foreach $key (keys %delete_list) {
if ($delete_list{$key}) { # Check to see if any items weren't deleted
$errstr .= "$key,"; # that should have been.
}
}


I've tested to be sure there's no syntax errors, but I haven't seen whether it will actually work. :) If something doesn't get deleted, it will display the number, but with any luck you won't have that problem.</


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] fatal error: Undefined subroutine in sort at db.cgi line 855 In reply to
JPDeni,

Thanks for the code.
I have the file upload mod running but I was able to work the code that you posted into what I have and it works.......except for the minor fact that the last letter of the recipe name is not being displayed when the deleted confirmation message is displayed.

Chef Mars
Quote Reply
Re: [mars2] fatal error: Undefined subroutine in sort at db.cgi line 855 In reply to
Cool that you could work it out. Once you get into working with this stuff, it does all make sense. :)

You can probably just delete the line

Code:

chop($succstr); # Remove trailing delimeter


which should give you your last letter back. The original has commas between the field numbers and this line elminates that last comma. But you probably are just doing one at a time, so it's not going to be an issue.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] fatal error: Undefined subroutine in sort at db.cgi line 855 In reply to
Deleting
Quote:
chop($succstr); # Remove trailing delimeter
fixed the minor problem.

"gracias otra vez"

Chef Mars


Quote Reply
Re: [mars2] fatal error: Undefined subroutine in sort at db.cgi line 855 In reply to
de nada!!

:-D


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.