PDA

View Full Version : Syntax error in FROM clause.


BarrMan
12-10-2005, 04:29 PM
I get this error when i have page=(number) on the querystring.
Syntax error in FROM clause.
/bestforums/forums.asp, line 47
To see better what i'm talking about please look at this link: http://e.domaindlx.com/BarrMan/BestForums/search.asp and write "thread" (doesn't matter if its set to all forums or just one forum, it will have paging on both), then try to move a page and you'll see the error.
This is part of my code:
<%
If Request.QueryString("s") = 1 Then
Dim PageSize, CurrentPage, PageCount, word, forum, foption, Counter, sCounter
Counter = 0
sCounter = 0
forum = Request.Form("forum")
foption = Request.Form("option")
word = Request.Form("word")
PageSize = 10
Rs.PageSize = PageSize
Rs.CacheSize = PageSize
If forum = "allforums" Then
For i = 1 To 16
If foption = "both" Then
SQL = "SELECT * FROM forum#" & i & " WHERE title LIKE '%" & word & "%' OR body LIKE '%" & word & "%'"
Else
SQL = "SELECT * FROM forum#" & i & " WHERE " & foption & " LIKE '%" & word & "%'"
End If
<!--Causing Problem!--> Rs.Open SQL, Conn, 3, 3 <!--Line 47!-->
PageCount = PageCount + Rs.PageCount
Rs.Close
Next
Else
If foption = "both" Then
SQL = "SELECT * FROM " & forum & " WHERE title LIKE '%" & word & "%' OR body LIKE '%" & word & "%'"
Else
SQL = "SELECT * FROM " & forum & " WHERE " & foption & " LIKE '%" & word & "%'"
End If
Rs.Open SQL, Conn, 3, 3
PageCount = Rs.PageCount
Rs.Close
End If

If Request.QueryString("page") = "" Then
CurrentPage = 1
Else
CurrentPage = Cint(Request.QueryString("page"))
End If

Function HighlightText(str)
If IsEmpty(str) or IsNull(str) Then Exit Function
str = Replace(str,word,"<div id=HLT>" & word & "</div>")
HighlightText = str
End Function


%>
<b>Search settings: </b>
<%If Request.Form("forum") = "allforums" Then
Response.Write "all the forums"
Else
Response.Write Request.Form("forum")
End If

%></b></td></tr>
<tr><td><table>
<tr><td width="350px">Current page <b><%=CurrentPage%></b> of <b><%=PageCount%></b></td>
<td width="350px" align="right">
<%
If CurrentPage < 3 Then
If PageCount <= 5 Then
For i = 1 To PageCount
If i = CurrentPage Then
Response.Write i & VBCrlf
Else
Response.Write "<a href=forums.asp?s=1&page=" & i & ">" & i & "</a>" & VBcrlf
End If
Next
Else
For i = 1 To 5
If i = CurrentPage Then
Response.Write i & VBCrlf
Else
Response.Write "<a href=forums.asp?s=1&page=" & i & ">" & i & "</a>" & VBcrlf
End If
Next
End If
Else
If PageCount >= (CurrentPage + 2) Then
For i = (CurrentPage - 2) To (CurrentPage + 2)
If i = CurrentPage Then
Response.Write i & VBCrlf
Else
Response.Write "<a href=forums.asp?s=1&?page=" & i & ">" & i & "</a>" & VBcrlf
End If
Next
Else
For i = 1 To PageCount
If i = CurrentPage Then
Response.Write i & VBCrlf
Else
Response.Write "<a href=forums.asp?s=1&page=" & i & ">" & i & "</a>" & VBcrlf
End If
Next
End If
End If
%>

Anyone got a clue what's the problem?
Thanks.

BarrMan
12-10-2005, 05:25 PM
Problem solved, i wrote:
response.write sql
response.end
before the problem occurs.
The results were : "SELECT * FROM WHERE title LIKE '% %'"
so i passed the page settings via querystring.