Forums
This topic is locked
Search results showing way to many results
Posted 08 Nov 2005 12:47:52
1
has voted
08 Nov 2005 12:47:52 andy bertaut posted:
Hi GuysI have a search page here:
d1956485.u35.hosting365.ie/asp/search.asp
When I perform a search the results page here:
d1956485.u35.hosting365.ie/asp/search_results.asp
displays results that have nothing to do with the search. I have the recordset set to Form variable, the filtering on "Contains". I cannot figure this one out. I have done this so many times and it's so easy but this one refuses to work. If anyone can spot anything in the code, I'd be a happy man.
Cheers
Andy
Replies
Replied 08 Nov 2005 13:47:24
08 Nov 2005 13:47:24 Michael Behan replied:
from my couple of test searches it seems to always return everything.
so it could be just something small in the name of the search field or where you use that in your recordset on the next page.
if you post the code for the recordset here it will make it a bit easier to see exactly whats wrong.
so it could be just something small in the name of the search field or where you use that in your recordset on the next page.
if you post the code for the recordset here it will make it a bit easier to see exactly whats wrong.
Replied 08 Nov 2005 13:52:42
08 Nov 2005 13:52:42 andy bertaut replied:
I should have done this from the off...here is the code for the recordset:
<%
var rsSEARCH = Server.CreateObject("ADODB.Recordset"
rsSEARCH.ActiveConnection = MM_connSLEVIN_STRING;
rsSEARCH.Source = "SELECT ProductCode, Name, Brochuredescription FROM slevin_site WHERE Brochuredescription LIKE '%"+ rsSEARCH__MMColParam.replace(/'/g, "''" + "%'";
rsSEARCH.CursorType = 0;
rsSEARCH.CursorLocation = 2;
rsSEARCH.LockType = 1;
rsSEARCH.Open();
var rsSEARCH_numRows = 0;
%>
<%
var rsSEARCH = Server.CreateObject("ADODB.Recordset"
rsSEARCH.ActiveConnection = MM_connSLEVIN_STRING;
rsSEARCH.Source = "SELECT ProductCode, Name, Brochuredescription FROM slevin_site WHERE Brochuredescription LIKE '%"+ rsSEARCH__MMColParam.replace(/'/g, "''" + "%'";
rsSEARCH.CursorType = 0;
rsSEARCH.CursorLocation = 2;
rsSEARCH.LockType = 1;
rsSEARCH.Open();
var rsSEARCH_numRows = 0;
%>
Replied 08 Nov 2005 14:39:40
08 Nov 2005 14:39:40 Michael Behan replied:
can you also show the bit of code (usually appears just above the recordset code) that defines rsSEARCH__MMColParam
i reckon the problem will be to do with that.
i reckon the problem will be to do with that.
Replied 08 Nov 2005 17:46:42
08 Nov 2005 17:46:42 andy bertaut replied:
here ya go, thanks for the feedback:
<%
var rsSEARCH__MMColParam = "1";
if (String(Request.Form("SearchForm") != "undefined" &&
String(Request.Form("SearchForm") != "" {
rsSEARCH__MMColParam = String(Request.Form("SearchForm");
}
%>
SearchForm is the name of the form the users use to search for products
<%
var rsSEARCH__MMColParam = "1";
if (String(Request.Form("SearchForm") != "undefined" &&
String(Request.Form("SearchForm") != "" {
rsSEARCH__MMColParam = String(Request.Form("SearchForm");
}
%>
SearchForm is the name of the form the users use to search for products
Replied 08 Nov 2005 18:27:48
08 Nov 2005 18:27:48 Michael Behan replied:
you have to use the name of the form field rather than the form itself.
So if you change SearchForm to Search (I think this is what you called the search field) it should work.
So if you change SearchForm to Search (I think this is what you called the search field) it should work.
Replied 09 Nov 2005 15:33:23
09 Nov 2005 15:33:23 andy bertaut replied:
did u ever finally get it right and groan at your own stupidity???? Thanks Micheal, the second I read that i realised you were right and proceeded to call myself every idiot under the sun.
Replied 10 Nov 2005 00:49:34
10 Nov 2005 00:49:34 Michael Behan replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>did u ever finally get it right and groan at your own stupidity????<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
YES! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Sometimes the simplest mistakes are the hardest ones to spot
YES! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Sometimes the simplest mistakes are the hardest ones to spot