Another thread dug up from the dusty past...
When you have a problem like this, go through your code (either on screen or printed), and put a letter by each curly bracket, and make sure they match open- and close-wise, and maybe put notes in for the closing ones. Ignore the smaller ones, like "$rec{$field}", since it's obvious that both brackets are there.
Example:
sub build_html_record { #A
# --------------------------------------------------------
# Builds a record based on the config information.
#
my (%rec) = @_;
my ($output, $field);
$output = "<p><table border=1 width=450>\n";
foreach $field (@db_cols) { #B
next if ($db_form_len{$field} == -1);
# >>> Admin URL View mod
if ($field eq "URL" && $rec{$field} ne "") { #C
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font><a href="$rec{$field}" target="_blank">$rec{$field}</a></font></td></tr>~;
} #/C
else { #D
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font>$rec{$field}</font></td></tr>
~;
} #/D
# >>> Original code:
# $output .= qq~
# <tr><td align=right valign=top width=20%><$font>$field:</font></td>
# <td width=80%><$font>$rec{$field}</font></td></tr>
# ~;
# <<< Admin URL View mod
} #/B ends 'foreach'
$output .= "</table></p>\n";
return $output;
} #/A
Here are the subs with the code added for this mod, you can just paste these in if you have not made any other changes to your files:
# --------------------------------------------------------
# Builds a record based on the config information.
#
my (%rec) = @_;
my ($output, $field);
$output = "<p><table border=1 width=450>\n";
foreach $field (@db_cols) {
next if ($db_form_len{$field} == -1);
# >>> Admin URL View mod
if ($field eq "URL" && $rec{$field} ne "") {
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font><a href="$rec{$field}" target="_blank">$rec{$field}</a></font></td></tr>~;
}
else {
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font>$rec{$field}</font></td></tr>
~;
}
# >>> Original code:
# $output .= qq~
# <tr><td align=right valign=top width=20%><$font>$field:</font></td>
# <td width=80%><$font>$rec{$field}</font></td></tr>
# ~;
# <<< Admin URL View mod
}
$output .= "</table></p>\n";
return $output;
}sub build_html_record_form {
# --------------------------------------------------------
# Builds a record form based on the config information.
#
my ($output, $field, $multiple, $name);
($_[0] eq "multiple") and ($multiple = 1) and shift;
my (%rec) = @_; $output = "<p><table border=1>";# Go through a little hoops to only load category list when absolutely neccessary.
if ($in{'db'} eq 'links') {
exists $db_select_fields{$db_cols[$db_category]}
or ($db_select_fields{$db_cols[$db_category]} = join (",", &category_list));
}
else {
$db_select_fields{'Related'} or
($db_select_fields{'Related'} = $db_select_fields{'Mult-Related'} = join ",", &category_list);
} foreach $field (@db_cols) {
# Set the field name to field-key if we are doing multiple forms.
$multiple ? ($name = "$field-$rec{$db_key}") : ($name = $field);
if ($db_select_fields{"Mult-$field"}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name, "MULTIPLE SIZE=3") . "</td></tr>\n"; }
elsif ($db_select_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_radio_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_radio_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_checkbox_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_checkbox_field ($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_form_len{$field} =~
/(\d+)x(\d+)/) { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><textarea wrap="virtual" name="$name" cols="$1" rows="$2">$rec{$field}</textarea></td></tr>\n~; }
elsif ($db_form_len{$field} == -1) { $output = qq~<input type=hidden name="$field" value="$rec{$field}">\n$output~; }
# >>> Admin URL View mod
else {
if ($field eq "URL" && $rec{$field} ne "") { $output .= qq~<tr><td align=right valign=top width=20%><$font><a href="$rec{$field}" target="_blank">$field</a>:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
else { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
}
# >>> Original code:
# else { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
# <<< Admin URL View mod
} # ends 'foreach'
$output .= "</table></p>\n";
return $output;
}
Leonard
aka PerlFlunkie
When you have a problem like this, go through your code (either on screen or printed), and put a letter by each curly bracket, and make sure they match open- and close-wise, and maybe put notes in for the closing ones. Ignore the smaller ones, like "$rec{$field}", since it's obvious that both brackets are there.
Example:
sub build_html_record { #A
# --------------------------------------------------------
# Builds a record based on the config information.
#
my (%rec) = @_;
my ($output, $field);
$output = "<p><table border=1 width=450>\n";
foreach $field (@db_cols) { #B
next if ($db_form_len{$field} == -1);
# >>> Admin URL View mod
if ($field eq "URL" && $rec{$field} ne "") { #C
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font><a href="$rec{$field}" target="_blank">$rec{$field}</a></font></td></tr>~;
} #/C
else { #D
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font>$rec{$field}</font></td></tr>
~;
} #/D
# >>> Original code:
# $output .= qq~
# <tr><td align=right valign=top width=20%><$font>$field:</font></td>
# <td width=80%><$font>$rec{$field}</font></td></tr>
# ~;
# <<< Admin URL View mod
} #/B ends 'foreach'
$output .= "</table></p>\n";
return $output;
} #/A
Here are the subs with the code added for this mod, you can just paste these in if you have not made any other changes to your files:
Code:
sub build_html_record { # --------------------------------------------------------
# Builds a record based on the config information.
#
my (%rec) = @_;
my ($output, $field);
$output = "<p><table border=1 width=450>\n";
foreach $field (@db_cols) {
next if ($db_form_len{$field} == -1);
# >>> Admin URL View mod
if ($field eq "URL" && $rec{$field} ne "") {
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font><a href="$rec{$field}" target="_blank">$rec{$field}</a></font></td></tr>~;
}
else {
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font>$rec{$field}</font></td></tr>
~;
}
# >>> Original code:
# $output .= qq~
# <tr><td align=right valign=top width=20%><$font>$field:</font></td>
# <td width=80%><$font>$rec{$field}</font></td></tr>
# ~;
# <<< Admin URL View mod
}
$output .= "</table></p>\n";
return $output;
}sub build_html_record_form {
# --------------------------------------------------------
# Builds a record form based on the config information.
#
my ($output, $field, $multiple, $name);
($_[0] eq "multiple") and ($multiple = 1) and shift;
my (%rec) = @_; $output = "<p><table border=1>";# Go through a little hoops to only load category list when absolutely neccessary.
if ($in{'db'} eq 'links') {
exists $db_select_fields{$db_cols[$db_category]}
or ($db_select_fields{$db_cols[$db_category]} = join (",", &category_list));
}
else {
$db_select_fields{'Related'} or
($db_select_fields{'Related'} = $db_select_fields{'Mult-Related'} = join ",", &category_list);
} foreach $field (@db_cols) {
# Set the field name to field-key if we are doing multiple forms.
$multiple ? ($name = "$field-$rec{$db_key}") : ($name = $field);
if ($db_select_fields{"Mult-$field"}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name, "MULTIPLE SIZE=3") . "</td></tr>\n"; }
elsif ($db_select_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_radio_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_radio_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_checkbox_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_checkbox_field ($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_form_len{$field} =~
/(\d+)x(\d+)/) { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><textarea wrap="virtual" name="$name" cols="$1" rows="$2">$rec{$field}</textarea></td></tr>\n~; }
elsif ($db_form_len{$field} == -1) { $output = qq~<input type=hidden name="$field" value="$rec{$field}">\n$output~; }
# >>> Admin URL View mod
else {
if ($field eq "URL" && $rec{$field} ne "") { $output .= qq~<tr><td align=right valign=top width=20%><$font><a href="$rec{$field}" target="_blank">$field</a>:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
else { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
}
# >>> Original code:
# else { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
# <<< Admin URL View mod
} # ends 'foreach'
$output .= "</table></p>\n";
return $output;
}
Leonard
aka PerlFlunkie