Gossamer Forum
Home : Products : DBMan : Customization :

Strange get_record problem

Quote Reply
Strange get_record problem
Hi!

I have a problem concerning the get_record subroutine.

I have a page where I need to drag two records from the default db. I use this code:

$compare = $in{compare};
my (@array) = split (/\Q~~\E/o, $compare);
my (%rec) = &get_record($array[0]);
my (%rec1) = &get_record($array[1]);


This works out just fine. $array[0] and $array[1] are the IDs of the two records. Now the strange part comes: When I am logged in as admin, the get_record works just fine, but when I want to enter the page as a default-user (uid=default), it returns no records. I've tried printing out the IDs, and they are still there, so it must be the get_record routine that is the problem.

My get_record subroutine looks like this:

sub get_record {
# --------------------------------------------------------
# Given an ID as input, get_record returns a hash of the
# requested record or undefined if not found.


my ($key, $found, $line, @data, $field, $restricted);
$key = $_[0];
$found = 0;
($restricted = 1) if ($auth_modify_own and !$per_admin);


open (DB, "<$db_file_name") or &cgierr("error in get_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
$line = $_; chomp ($line);
@data = &split_decode($line);
next LINE if ($restricted and ($db_userid ne $data[$auth_user_field]));
if ($data[$db_key_pos] eq $key) {
$found = 1;
for ($i = 0; $i <= $#db_cols; $i++) { # Map the array columns to a hash.
$rec{$db_cols[$i]} = $data[$i];
}
last LINE;
}
}
close DB;
$found ?
(return %rec) :
(return undef);
}


I hope you will help me. I am really confused.

Regards,

Alex
Subject Author Views Date
Thread Strange get_record problem AlexVB 1791 May 8, 2002, 3:18 PM
Thread Re: [AlexVB] Strange get_record problem
LoisC 1721 May 8, 2002, 3:35 PM
Post Re: [LoisC] Strange get_record problem
AlexVB 1713 May 8, 2002, 11:28 PM