<% Option Explicit %> <% Dim txtSearchTerms, strTxt, txtSearchShow, SearchText txtSearchTerms = Replace(Request("SearchText"),"""","") If txtSearchTerms = "" Then Response.Redirect "searchform.htm" txtSearchTerms = Replace(txtSearchTerms,"*","%") txtSearchTerms = Trim(txtSearchTerms) txtSearchTerms = Replace(txtSearchTerms,"'","''") txtSearchShow = txtSearchTerms Do While InStr(1, txtSearchTerms, " ", 1) <> 0 strTxt = Replace(txtSearchTerms, " ", " ") Loop Dim Search Search = txtSearchTerms Dim arrSearchTerms, iwordCount, strSQL arrSearchTerms = Split(txtSearchTerms," ") iwordCount = ubound(arrSearchTerms) strSQL = " contents LIKE" Dim txtAdd, iCount, spaceCheck spaceCheck = False For iCount = 0 to iwordCount Select Case arrSearchTerms(iCount) Case "AND","&","+" If iCount > 0 THEN txtAdd = "%' " strSQL = strSQL & txtAdd & " AND contents LIKE" spaceCheck = False End IF Case "NOT","<>" If iCount > 0 THEN txtAdd = "%' " strSQL = strSQL & txtAdd & " AND contents NOT LIKE" spaceCheck = False End if Case "OR" If iCount > 0 THEN txtAdd = "%' " strSQL = strSQL & txtAdd & "OR contents LIKE" spaceCheck = False End if Case Else If spaceCheck = True Then txtAdd = " " strSQL = strSQL & txtAdd & arrSearchTerms(iCount) Else spaceCheck = True txtAdd = " '%" strSQL = strSQL & txtAdd & arrSearchTerms(iCount) End If End Select Next strSQL = strSQL & "%'" IF InStr(strSQL, "(") > 0 Then strSQL = Replace(strSQL,"contents LIKE '%(", "(contents LIKE '%") strSQL = Replace(strSQL,")%'", "%')") strSQL = Replace(strSQL, "contents NOT LIKE '%(", "(contents NOT LIKE '%") End IF Session("strSQL")=strSQL Response.Redirect("pagedresults.asp") %>