I have a little problem getting the the relational mod from JPDeni working.
Thanks to the great tutorial and documentation of JPDeni, I managed to get set it up for the biggest part. The only problem I have now, and I am not skilled enough to find a solution by myself, is to display the many "items" of one "user". Everything else works, also displaying the "item" with the users info.
The error:
CGI ERROR
==========================================
Error Message : fatal error: Undefined sort subroutine "main::_ascend" called at db.cgi line 471.
Script Location : db.cgi
Perl Version : 5.00502
Setup File : user.cfg
User ID : jan
Session ID : jan.958731502736
Form Variables
-------------------------------------------
UserID : agabird
UserID-lt : B>agabird
mh : 100
sb : 4
From the user_html.pl the sub html_record looks like this:
sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.
my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);
my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';
$url{'UserEmail'} = $rec{'UserEmail'};
$url{'UserEmail'} =~ s/<\/?B>//g;
$url{'UserUrl'} = $rec{'UserUrl'};
$url{'UserUrl'} =~ s/<\/?B>//g;
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">|;
if ($per_admin) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserID:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'UserID'}</Font></TD></TR>
|;
}
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserName:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'UserName'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserCountry:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'UserCountry'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserState:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'UserState'}</Font></TD></TR>|;
if ($rec{'UserCity'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserCity:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'UserCity'}</Font></TD></TR>
|;
}
print qq||;
if ($rec{'UserPhone'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserPhone:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'UserPhone'}</Font></TD></TR>
|;
}
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserEmail:</FONT></TD>
<TD WIDTH="80%"> <$font><a href="mailto:$url{'UserEmail'}">$rec{'UserEmail'}</a>|;
if ($rec{'UserUrl'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserUrl:</FONT></TD>
<TD WIDTH="80%"> <$font><a href="$url{'UserUrl'}">$rec{'UserUrl'}</a>
|;
}
print qq|
</TABLE>
|;
&switch_to_item;
undef %in;
$in{'UserID'} = $rec{'UserID'};
$in{'sb'} = 4;
$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=item&uid=$db_uid&ItemID=$rec2{'ItemID'}&view_records=1">$rec2{'Type'}
</a><BR>
</td></tr>|;
}
print qq|
</TABLE>|;
}
&switch_to_user;
}
The changes I made in db.cgi was only adding the following :
##########################################################
sub switch_to_item {
#-----------------------------------------------------
$cols = 'UserID,ItemID,Rubr,Type,DateAdded,Description';
@db_cols = split /,/,$cols;
$db_file_name = $db_script_path . "/item.db";
}
sub switch_to_user {
#-----------------------------------------------------
$cols = 'UserID,UserName,UserCountry,UserState,UserCity,UserPhone,UserEmail,UserUrl';
@db_cols = split /,/,$cols;
$db_file_name = $db_script_path . "/user.db";
$db_key_pos = 0;
}
##########################################################
Please could anyone tell me what I'm doing wrong??
Thanks to the great tutorial and documentation of JPDeni, I managed to get set it up for the biggest part. The only problem I have now, and I am not skilled enough to find a solution by myself, is to display the many "items" of one "user". Everything else works, also displaying the "item" with the users info.
The error:
CGI ERROR
==========================================
Error Message : fatal error: Undefined sort subroutine "main::_ascend" called at db.cgi line 471.
Script Location : db.cgi
Perl Version : 5.00502
Setup File : user.cfg
User ID : jan
Session ID : jan.958731502736
Form Variables
-------------------------------------------
UserID : agabird
UserID-lt : B>agabird
mh : 100
sb : 4
From the user_html.pl the sub html_record looks like this:
sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.
my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);
my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';
$url{'UserEmail'} = $rec{'UserEmail'};
$url{'UserEmail'} =~ s/<\/?B>//g;
$url{'UserUrl'} = $rec{'UserUrl'};
$url{'UserUrl'} =~ s/<\/?B>//g;
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">|;
if ($per_admin) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserID:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'UserID'}</Font></TD></TR>
|;
}
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserName:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'UserName'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserCountry:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'UserCountry'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserState:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'UserState'}</Font></TD></TR>|;
if ($rec{'UserCity'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserCity:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'UserCity'}</Font></TD></TR>
|;
}
print qq||;
if ($rec{'UserPhone'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserPhone:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'UserPhone'}</Font></TD></TR>
|;
}
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserEmail:</FONT></TD>
<TD WIDTH="80%"> <$font><a href="mailto:$url{'UserEmail'}">$rec{'UserEmail'}</a>|;
if ($rec{'UserUrl'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>UserUrl:</FONT></TD>
<TD WIDTH="80%"> <$font><a href="$url{'UserUrl'}">$rec{'UserUrl'}</a>
|;
}
print qq|
</TABLE>
|;
&switch_to_item;
undef %in;
$in{'UserID'} = $rec{'UserID'};
$in{'sb'} = 4;
$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=item&uid=$db_uid&ItemID=$rec2{'ItemID'}&view_records=1">$rec2{'Type'}
</a><BR>
</td></tr>|;
}
print qq|
</TABLE>|;
}
&switch_to_user;
}
The changes I made in db.cgi was only adding the following :
##########################################################
sub switch_to_item {
#-----------------------------------------------------
$cols = 'UserID,ItemID,Rubr,Type,DateAdded,Description';
@db_cols = split /,/,$cols;
$db_file_name = $db_script_path . "/item.db";
}
sub switch_to_user {
#-----------------------------------------------------
$cols = 'UserID,UserName,UserCountry,UserState,UserCity,UserPhone,UserEmail,UserUrl';
@db_cols = split /,/,$cols;
$db_file_name = $db_script_path . "/user.db";
$db_key_pos = 0;
}
##########################################################
Please could anyone tell me what I'm doing wrong??