Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 search.asp (member searching)
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Brett Alcock
New Member

65 Posts

Posted - 05 December 2002 :  09:20:17  Show Profile
I think there is some sort of problem with the comparison of null values in search.asp. Specifically around line 218 where we have the following check of search keyword and member id.
if Request.QueryString("mode") = "DoIt" then
	if Request.Form("Search") <> "" or Request.QueryString("MEMBER_ID") <> "" then
		if Request.Form("Search") <> "" then
Now I am not sure what the correct operation should be but looking at this code I belive that if you do not supply a keyword but do choose a member then the search should find all postings from that member. However what you always get is the "You must supply keywords" message, which is triggerd by the second line of code above (try it now in this forum it does the same). What I normally do is supply a space for the keyword to get around this.

However if we compare MEMBER_ID against something rather than a null string then we do get all posts from whatever member is chosen. For example:
if Request.QueryString("mode") = "DoIt" then
	if Request.Form("Search") <> "" or Request.QueryString("MEMBER_ID") <> "x" then
		if Request.Form("Search") <> "" then
This will find all posts from any member chosen in the drop down list box.

I did experience a similar problem in setup.asp where a comparison of undeclared variables against null values was not working in a similar way, however this was simply solved by declaring the variables in config.asp. see http://forum.snitz.com/forum/topic.asp?TOPIC_ID=33898&SearchTerms=, for that issue.

Edited by - Brett Alcock on 05 December 2002 09:34:52

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 05 December 2002 :  09:22:07  Show Profile  Visit HuwR's Homepage
YOU MUST supply a keyword, that is how it is supposed to work
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 05 December 2002 :  09:25:46  Show Profile  Visit HuwR's Homepage
In explanation, the search page is meant for you to use to find answers to your problems, and not so you can list all the posts a particular person has made.
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 05 December 2002 :  09:38:06  Show Profile  Visit HuwR's Homepage
the habbit of editing posts after someone has replied is extremely irritating unless you indicate what you have changed.
Go to Top of Page

Brett Alcock
New Member

65 Posts

Posted - 05 December 2002 :  09:50:48  Show Profile
Thanks for the response, but why then does the conditional use 'or' not 'and' ?
if Request.Form("Search") <> "" or Request.QueryString("MEMBER_ID") <> "" then
the code is written to allow progression if one or the other is supplied (a keyword or a member id) only if neither are supplied should you get the "You must supply keywords" message, and of course the search does indeed work when we sort out the MEMBER_ID comparison with a null value, i.e if the MEMBER_ID comparison yeilds true when a member is chosen regardless if a keyword is supplied or not.
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 05 December 2002 :  10:56:40  Show Profile  Visit HuwR's Homepage
because if you used an 'and' it would never do a search unless you chose a keyword and a member, ie you would ALWAYS have to select a member in order to search.

There is nothing wrong with the code, it does what it is supposed to do. Just because it doesn't do what you want it to, doesn't make it wrong.


Go to Top of Page

Brett Alcock
New Member

65 Posts

Posted - 05 December 2002 :  11:02:40  Show Profile
Ok can see what is going on now.

Request.Form("Search") is a value from the standard search form and Request.QueryString("MEMBER_ID") is not, I can see now that the later only has a value when search.asp is called by something like the "Find all non-archived posts from Member" link in a members profile.

Still can't really think of a good reason why I should not mod the operation slightly to allow the standard form to find all posts from a given member.
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 05 December 2002 :  11:03:19  Show Profile  Visit HuwR's Homepage
Also don't forget that search.asp is used by other pages, ie your profile, the MEBER_ID check is for this code, and is not related to the search page at all which does not pass MEMBER_ID at all, it uses a form variable called SearchMember
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 05 December 2002 :  11:04:27  Show Profile  Visit HuwR's Homepage
well done

You can mod it to do whatever you want.
Go to Top of Page

Brett Alcock
New Member

65 Posts

Posted - 05 December 2002 :  11:27:24  Show Profile
All I had to do is adjust the conditional around line 220 so that it is true when a member has been chosen on the form.

if Request.Form("Search") <> "" or cLng(Request.Form("SearchMember")) <> 0 or Request.QueryString("MEMBER_ID")<>"" then


For good measure I also adjusted the error message to state "You must enter keywords or choose a member".
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 05 December 2002 :  11:42:29  Show Profile  Visit HuwR's Homepage
yep, that should be ok, I will move this to the MOD forum incase anyone else wants to use your code.
Go to Top of Page

Brett Alcock
New Member

65 Posts

Posted - 05 December 2002 :  12:25:07  Show Profile
I have also adjusted the following around line 403 from
		if Request.Form("Search") <> "" then
			Response.Write	"          " & getCurrentIcon(strIconBlank,"","align=""absmiddle""") & getCurrentIcon(strIconBar,"","align=""absmiddle""") & getCurrentIcon(strIconFolderOpenTopic,"","align=""absmiddle""") & " Search Results for: " & chkString(Request.Form("Search"),"display")
		elseif Request.QueryString("MEMBER_ID") <> "" then
			Response.Write	"          " & getCurrentIcon(strIconBlank,"","align=""absmiddle""") & getCurrentIcon(strIconBar,"","align=""absmiddle""") & getCurrentIcon(strIconFolderOpenTopic,"","align=""absmiddle""") & " Search Results for: All non-archived Topics that contain posts by " & getMemberName(cLng(Request.QueryString("MEMBER_ID")))
		end if
to
		if Request.Form("Search") <> "" or Request.Form("SearchMember") <> 0 then
			Response.Write	"          " & getCurrentIcon(strIconBlank,"","align=""absmiddle""") & getCurrentIcon(strIconBar,"","align=""absmiddle""") & getCurrentIcon(strIconFolderOpenTopic,"","align=""absmiddle""") & " Topics with posts"
			if Request.Form("Search") <> "" then
				Response.Write " containing " & chkString(Request.Form("Search"),"display")
			end if		
			if Request.Form("SearchMember") <> 0 then
				Response.Write " by " & getMemberName(cLng(Request.Form("SearchMember")))
			end if 
		elseif Request.QueryString("MEMBER_ID") <> "" then
			Response.Write	"          " & getCurrentIcon(strIconBlank,"","align=""absmiddle""") & getCurrentIcon(strIconBar,"","align=""absmiddle""") & getCurrentIcon(strIconFolderOpenTopic,"","align=""absmiddle""") & " Non-archived topics with posts by " & getMemberName(cLng(Request.QueryString("MEMBER_ID")))
		end if
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000 Version 3.4.07