By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,372 Members | 1,950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,372 IT Pros & Developers. It's quick & easy.

trying to modify my search script

P: 3
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?
Sep 10 '08 #1
Share this Question
Share on Google+
4 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
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
Sep 10 '08 #2

eWish
Expert 100+
P: 971
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
Sep 10 '08 #3

P: 3
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.
Sep 10 '08 #4

eWish
Expert 100+
P: 971
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
Sep 10 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.