Connecting Tech Pros Worldwide Help | Site Map

trying to modify my search script

Newbie
 
Join Date: Sep 2008
Posts: 3
#1: Sep 10 '08
I am modifying a search script, but when I change it, it only searches for 2 of the 3 fields. I believe the problem is in a chunk of it here.
Expand|Select|Wrap|Line Numbers
  1. if( $INFO[0] eq "$FORM{title}" && $INFO[1] =~ /$FORM{subject}/ && $INFO[2] =~ /$FORM{search}/ ) {
it only searches for the title and the search is a text line. i need it to search for the title subject, and search categories.

How can i change this code so it searches for all 3?
numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,565
#2: Sep 10 '08

re: trying to modify my search script


Why are you using "eq" for the first match, but regex's for the rest? Without seeing what its trying to match and the rest of the code, its going to be tough to help you.

Regards,

Jeff
eWish's Avatar
Moderator
 
Join Date: Jul 2007
Location: Arkansas
Posts: 900
#3: Sep 10 '08

re: trying to modify my search script


Currently the way it is written, you must match on three occurrences before it will enter inside of the if statement. Would you rather search for a match on any of the three elements?

--Kevin
Newbie
 
Join Date: Sep 2008
Posts: 3
#4: Sep 10 '08

re: trying to modify my search script


Quote:

Originally Posted by eWish

Currently the way it is written, you must match on three occurrences before it will enter inside of the if statement. Would you rather search for a match on any of the three elements?

--Kevin

ideally the script would search for any input given.
eWish's Avatar
Moderator
 
Join Date: Jul 2007
Location: Arkansas
Posts: 900
#5: Sep 10 '08

re: trying to modify my search script


Then you would need to use the || in lieu of &&

Expand|Select|Wrap|Line Numbers
  1. if ($FORM[0] eq $title || 
  2.     $FORM[1] eq $subject || 
  3.     $FORM[2] eq $search) {
  4.  
  5. ....then do something here....
  6.  
  7. }
I hope that you are checking your data first. Never trust the user's input.

--Kevin
Reply