PDA

View Full Version : Problems with scanning the data base for matching results in search form


BarrMan
12-08-2005, 08:06 PM
I have alot of forums in my site that have thread name and thread body.
The search feature is built with "option" "forum" "word" which the word symbolizes the keyword entered.
You can see it in this code:
<%Dim word, Tarray(100), Barray(100), Count, msg
Count = 1
word = Request.Form("word")
If Request.Form("forum") = "allforums" Then
For i = 1 To 16
If Request.Form("option") = "both" Then
SQL = "SELECT * FROM forum#" & i & " WHERE title LIKE '%" & word & "%'"'OR body like '%" & word & "%'"
rs.open SQL, Conn
While Not rs.EOF
Tarray(Count) = rs("title")
Barray(Count) = rs("body")
Count = Count + 1
rs.movenext
Wend
End If
Next

Here in the code i'm trying to get all the match results of the search and keep them inside an array called TitleArray = Tarray and the second called BodyArray = Barray.
Something doesn't work there as it shows none of the records has been found, i already checked if the values returned from the search form are correct.
Can anyone look at my problem and see if he can point it?
Thanks

TheShaner
12-08-2005, 08:22 PM
Yours (I highlighted in red what was wrong):
SQL = "SELECT * FROM forum#" & i & " WHERE title LIKE '%" & word & "%'"'OR body like '%" & word & "%'"
Fixed:
SQL = "SELECT * FROM forum#" & i & " WHERE title LIKE '%" & word & "%' OR body like '%" & word & "%'"

-Shane