If I have a & in the category name and if I enter a site from "add a site" from that category, the drop down category list in the add a site form does not seem to pick that particular category. What gives?
Apr 5, 1999, 7:04 AM
Novice (10 posts)
Apr 5, 1999, 7:04 AM
Post #2 of 3
Views: 1761
I don't know PERL at all, so read this message with caution. I'm
responding in hopes that this thread won't drop out of site, and
that someone can help solve this problem. This is as far as I can get:
Look at the following line in add.cgi, sub main:
my %is_valid = map { $_ => 1 } &category_list;
add.cgi builds an associative array %is_valid using the map function.
map returns a list of all categories in the database, which it obtained
by invoking the category_list subroutine in the db_utils.pl file.
Default input $_ is set to 1 so field 1 of each record is stored--that's
the category name (field 0 is the ID number).
Now look at the following line in add.cgi, sub main:
$is_valid{$1} ? &site_html_add_form ($1) : &site_html_add_form ();
That's a conditional comparison. If the test "$is_valid{$1}" is true,
then sub site_html_add_form (subroutine within site_html_templates.pl)
grabs the add.html template and builds the add a site form with the
current category (stored in $1) automatically filled in.
If the test $is_valid{$1} is false, then sub site_html_add_form grabs
add.html and builds the form with the drop down category list.
Apparently, the test is being evaluated false for some reason. Maybe it's
because "&" is the bitwise logical operator "and" which screws up the test
when it's used in a subcategory name. The test reads to the & in the
subcategory name stored in $1, interprets it as "and", and can't match
characters preceding & "and" characters following & with anything stored
in is_valid, which does not interpret the & to mean "and".
That's a guess. Can anyone help out with this???
responding in hopes that this thread won't drop out of site, and
that someone can help solve this problem. This is as far as I can get:
Look at the following line in add.cgi, sub main:
my %is_valid = map { $_ => 1 } &category_list;
add.cgi builds an associative array %is_valid using the map function.
map returns a list of all categories in the database, which it obtained
by invoking the category_list subroutine in the db_utils.pl file.
Default input $_ is set to 1 so field 1 of each record is stored--that's
the category name (field 0 is the ID number).
Now look at the following line in add.cgi, sub main:
$is_valid{$1} ? &site_html_add_form ($1) : &site_html_add_form ();
That's a conditional comparison. If the test "$is_valid{$1}" is true,
then sub site_html_add_form (subroutine within site_html_templates.pl)
grabs the add.html template and builds the add a site form with the
current category (stored in $1) automatically filled in.
If the test $is_valid{$1} is false, then sub site_html_add_form grabs
add.html and builds the form with the drop down category list.
Apparently, the test is being evaluated false for some reason. Maybe it's
because "&" is the bitwise logical operator "and" which screws up the test
when it's used in a subcategory name. The test reads to the & in the
subcategory name stored in $1, interprets it as "and", and can't match
characters preceding & "and" characters following & with anything stored
in is_valid, which does not interpret the & to mean "and".
That's a guess. Can anyone help out with this???