Gossamer Forum
Home : Products : DBMan : Customization :

Number sign in search

Quote Reply
Number sign in search
Is there a way to change the number sign # when searching the database so it isn't treated as a comment line? I want to be able to search for a string containing "#" and have it output as "#" as well, but right now, any time I search for a string containing #, I get no search results. This is an important character for my database because it is a registration prefix... the # sign occurs only in this field, which is also the db_key. Also, searches that contain "&" ignore everything after it (e.g. if I was searching for "A&B Stop Sign" I would get a list of results of everything containing the letter "A"). Any help on a level I can understand (only have a small knowledge of perl programming) would be appreciated.
Thanks.

-Jennifer
Quote Reply
Re: Number sign in search In reply to
Thanks... I vaguely understand the escape character, but I still don't know how to get the form input of "#" converted to "\#" to be used in the search, but so only "#" is returned in the result. How do you get \ added before any # in a user's query?

-Jennifer
Quote Reply
Re: Number sign in search In reply to
UH...YOU ADD THE ESCAPE CHARACTER RIGHT BEFORE THE SPECIAL PERL CHARACTER THAT YOU WOULD LIKE TO PRINT RATHER THAN EXECUTE OR IGNORE!

LIKE I POSTED!

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------








Quote Reply
Re: Number sign in search In reply to
Yea...Use the escape character, \.

Like the following:

Code:
\#

Again, use the escape character for the & sign....

Code:
\&

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------








Quote Reply
Re: Number sign in search In reply to
Sorry - I'm not stupid - I got the printing the escape characters figured out just fine - I don't need to have # printed other than when it is contained in a database field (which prints fine) - the INITIAL search is now working for # (I don't know what was up with it before - I didn't change anything to make it work)... BUT not for "&" as this character devides up the query string - if I search for something like "a&b" everything after '&' is ignored, and anything matching 'a' is returned - is there a way to fix this?

[This message has been edited by knutsonj (edited February 08, 2000).]
Quote Reply
Re: Number sign in search In reply to
OK... still having problems... I have no problem with the HTML output...
It's the linked searches -

as the # is found in the field that is the db_key, it seems to not recognize it as a search that's a link. What happens is there's an initial search and records are returned, with one of the fields (Name) linked to another results page, using the db_key (Registration) to tell dbman which record to get. This works FINE for all links that DON'T contain '#" but will return me to the "Error: No search terms specified Search form" for any link which has a # in the Registration (db_key) field.
THAT is what the problem is, NOT simply printing "#" or "&" on a html result page!

check it out at:
http://137.22.100.69/cgi-bin/dbman/db.cgi

-Jen

[This message has been edited by knutsonj (edited February 08, 2000).]
Quote Reply
Re: Number sign in search In reply to
Use the following codes in your sub view_search routine (add them at the top before the print qq| codes):

Code:
foreach $column (@db_cols) {
$in{$column} =~ s/\#//g;
}

This should clear up the # problem. If this doesn't work, then try these codes:

Code:
$in{'$db_key'} =~ s/\#//g;

OR

Code:
$in{'Registration'} =~ s/\#//g;

In terms of the & sign...that is a problem because it is a special Perl character that breaks up arguments in the query string. At this time, I do not have solution for it other than use something else than &.

You could try searching the LINKS forums for "special characters" and you may find some codes that are applicable to this problem.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. Smile
----------------------










[This message has been edited by Eliot (edited February 08, 2000).]

[This message has been edited by Eliot (edited February 08, 2000).]
Quote Reply
Re: Number sign in search In reply to
It seems to work for the forms, but I still need help getting links that are returned from a search to work, such as:

<A HREF="$db_script_link_url&view_records_4=1&$db_key=$rec{'Registration'}">$rec{'Name'}</A>

where 'Registration' contains the number sign, #.
Quote Reply
Re: Number sign in search In reply to
Welp, add the following codes in your sub html_footer routine or where you have the link located, and also in the sub html_record:

Code:
foreach $column (@db_cols) {
$rec{$column} =~ s/\#//g;
}

AND

Code:
$rec{'$db_key'} =~ s/\#//g;
$rec{'Registration'} =~ s/\#//g;

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------








Quote Reply
Re: Number sign in search In reply to
Well, the links now work - to some extent - but the # does not show up in the search results - how do I fix that?

Also, subroutines needing input which includes the # don't seem to work correctly, and I'll get a list of errors such as:

# Odd number of elements in hash list.
File ':html.pl'; Line 223
# Odd number of elements in hash list.
File ':html.pl'; Line 234
# Odd number of elements in hash list.
File ':html.pl'; Line 223
# Odd number of elements in hash list.
File ':html.pl'; Line 259
# Odd number of elements in hash list.
File ':html.pl'; Line 223
# Odd number of elements in hash list.
File ':html.pl'; Line 284
# Odd number of elements in hash list.
File ':html.pl'; Line 306
# Odd number of elements in hash list.
File ':html.pl'; Line 306
# Odd number of elements in hash list.
File ':html.pl'; Line 223
# Odd number of elements in hash list.
File ':html.pl'; Line 284
# Odd number of elements in hash list.
File ':html.pl'; Line 306
# Odd number of elements in hash list.
File ':html.pl'; Line 306
# Odd number of elements in hash list.
File ':html.pl'; Line 223
# Odd number of elements in hash list.
File ':html.pl'; Line 259
# Odd number of elements in hash list.
File ':html.pl'; Line 223
# Odd number of elements in hash list.
File ':html.pl'; Line 284
# Odd number of elements in hash list.
File ':html.pl'; Line 306
# Odd number of elements in hash list.
File ':html.pl'; Line 306
# Odd number of elements in hash list.
File ':html.pl'; Line 223
# Odd number of elements in hash list.
File ':html.pl'; Line 284
# Odd number of elements in hash list.
File ':html.pl'; Line 306
# Odd number of elements in hash list.
File ':html.pl'; Line 306

I don't know what that means - try do a search for "#55156" as the horse's registration number at:

http://137.22.100.69/cgi-bin/dbman/db.cgi

and follow the link you get as a search result (which will display 55156, not #55156, as the registration number) - there will be diagnostic output that blends in with the background at the bottom of the page such as found above. And the pedigree will not fill in on the top side, because the registration number of that horse happens to contain a # as well, and therefore the subroutine seems to stop and doesn't return any more data.

[This message has been edited by knutsonj (edited February 08, 2000).]
Quote Reply
Re: Number sign in search In reply to
Try changing $rec to $in. I don't gaurantee this will work, but give it a shot.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. Smile
----------------------










[This message has been edited by Eliot (edited February 08, 2000).]
Quote Reply
Re: Number sign in search In reply to
well, that now displays the #, but the links stop working.... sigh....
Quote Reply
Re: Number sign in search In reply to
Welp, the only solution I have is what I provided with the $rec codes. I will have to give this some more thought.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------