Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Ola estava fazendo um sistema de busca e derrepente deu este erro\/ como posso corrigilo? vou deixar meu codigo abaixo para facilitar
Server Error in '/vestup02' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30084: 'For' must end with a matching 'Next'.
Source Error:
Line 128:
Line 129:'Loop to search for each search word entered by the user
Line 130:For intSQLLoopCounter = 0 To UBound(sarySearchWord)
Line 131:strSQL = strSQL & " OR Title LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
Line 132:strSQL = strSQL & " OR Keywords LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
Meu Codigo
<html>
<head>
<title>Dutty Search</title>
<script language="JavaScript">
.
function CheckForm () {
if (document.frmInterSaerch.search.value==""){
alert("Por favor insira uma palavra para realizar a busca");
document.frmInterSaerch.search.focus();
return false;
}
return true
}
// -->
</script>
</head>
<img src="header.png" border="0" usemap="#Map" />
<map name="Map" id="Map"><area shape="rect" coords="1,0,38,23" href="default.htm" />
<area shape="rect" coords="66,0,152,15" href="http://explorerfly.com" target="_blank" />
</map>
<body text="#000000" link="#66CCFF" vlink="#66CCFF" alink="#FF0000">
<form method="get" name="frmInterSaerch" action="search.aspx" onSubmit="return CheckForm();">
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
<td> <a href="add_url_form.htm">Adicione seu site ao Dutty Search</a> <a href="search.aspx?mode=new">
Novos Sites</a> <a href="search.aspx?mode=random">Escolher URL aleatoriamente</a></td>
</table>
<table cellpadding="0" cellspacing="0" width="90%" align="center">
<tr>
<td height="61" width="231" align="right" rowspan="3"><img src="logo2.png"
align="absmiddle" alt="Busca na web" style="height: 56px; width: 115px">
</td>
<td height="61" width="21" align="right" rowspan="3"> </td>
<td class="arial" height="29" width="634" valign="bottom"> Página de busca:
</td>
</tr>
<tr>
<td class="normal" height="2" width="634">
<input type="TEXT" name="search" maxlength="50" size="35" value="<% =Request.QueryString("search") %>">
<input type="submit" value="Busca Dutty" name="submit">
</td>
</tr>
<tr>
<td class="normal" height="29" width="634" valign="top"> Procurar por:
<input type="radio" name="mode" value="allwords" CHECKED>
Todas as palavras
<input type="radio" name="mode" value="anywords">
Qualquer uma das palavras </td>
</tr>
</table>
<%
'Dimension variables
Dim adoCon 'Database Connection Variable
Dim adoRec 'database Recordset Variable
Dim strAccessDB 'Holds the Access Database Name
Dim strSQL 'Database query sring
Dim intRecordPositionPageNum 'Holds the record position
Dim intRecordLoopCounter 'Loop counter for displaying the database records
Dim intTotalRecordsFound 'Holds the total number of records in the database
Dim intTotalNumPages 'holds the total number of pages in the database
Dim intLinkPageNum 'Holds the page number to be linked to
Dim strSearchKeywords 'Holds the keywords input by the user to be searched for
Dim strTitle 'Holds the URL Title
Dim strURL 'Holds the URL
Dim strDescription 'Holds the description of the URL
Dim sarySearchWord 'Holds the keywords for the URL
Dim intSQLLoopCounter 'Loop counter for the loop for the sql query
Dim intSearchWordLength 'Holds the length of the word to be searched
Dim blnSearchWordLenthOK 'Boolean set to false if the search word length is not OK
Dim intRecordDisplayFrom 'Holds the number of the search result that the page is displayed from
Dim intRecordDisplayTo 'Holds the number of the search result that the page is displayed to
Dim intRandomRecordNumber 'Holds a random number used to display a random URL
'Declare constants
' Change the following line to the number of entries you wish to have on each page and miniumum word length
Const intRecordsPerPage = 10 'Change this number to the amount of entries to be displayed on each page
Const intMinuiumSesrchWordLength = 2 'Change this to the minimum word length to be searched on
'Error handler
On error resume next
'If this is the first time the page is displayed then the page position is set to page 1
If Request.QueryString("PagePosition") = "" Then
intRecordPositionPageNum = 1
'Else the page has been displayed before so the page postion is set to the Record Position number
Else
intRecordPositionPageNum = CInt(Request.QueryString("PagePosition"))
End If
'Read in the search words to be searched
sarySearchWord = Split(Trim(Request.QueryString("search")), " ")
'Read in all the search words into one variable
strSearchKeywords = Trim(Request.QueryString("search"))
'Replace any less than or greater than signs with the HTML equivalent (stops people entering HTML tags)
strSearchKeywords = Replace(strSearchKeywords, "<", "<")
strSearchKeywords = Replace(strSearchKeywords, ">", ">")
'Initalise the word search length variable
blnSearchWordLenthOK = True
'Loop round to check that each word to be searched has more than the minimum word length to be searched
For intLoopCounter = 0 To UBound(sarySearchWord)
'Initialise the intSearchWordLength variable with the length of the word to be searched
intSearchWordLength = Len(sarySearchWord(intLoopCounter))
'If the word length to be searched is less than or equal to min word length then set the blnWordLegthOK to false
If intSearchWordLength <= intMinuiumSesrchWordLength Then
blnSearchWordLenthOK = False
End If
Next
'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM tblWebsites "
'If the user has selected to search any words then intalise the strSQL statement to search for any words in the database
If Request.QueryString("mode") = "anywords" Then
'Search for the first search word in the URL titles
strSQL = strSQL & "WHERE Title LIKE '%" & sarySearchWord(0) & "%'"
'Loop to search for each search word entered by the user
For intSQLLoopCounter = 0 To UBound(sarySearchWord)
strSQL = strSQL & " OR Title LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
strSQL = strSQL & " OR Keywords LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
strSQL = strSQL & " OR Description LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
Nex
End If
'If the user has selected to search for all words then intalise the strSQL statement to search for entries containing all the search words
If Request.QueryString("mode") = "allwords" Then
'Search for the first word in the URL titles
strSQL = strSQL & "WHERE Title LIKE '%" & sarySearchWord(0) & "%'
'Loop to search the URL titles for each word to be searched
For intSQLLoopCounter = 1 To UBound(sarySearchWord)
strSQL = strSQL & " AND Title LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
Next
'OR if the search words are in the keywords
strSQL = strSQL & " OR Keywords LIKE '%" & sarySearchWord(0) & "%'"
'Loop to search the URL keywords for each word to be searched
For intSQLLoopCounter = 1 To UBound(sarySearchWord)
strSQL = strSQL & " AND Keywords LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
Next
'Or if the search words are in the title
strSQL = strSQL & " OR Description LIKE '%" & sarySearchWord(0) & "%'"
'Loop to search the URL description for each word to be searched
For intSQLLoopCounter = 1 To UBound(sarySearchWord)
strSQL = strSQL & " AND Description LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
Next
End If
'If the user has selected to see newly enetred URL's then order the search results by date decending
If Request.QueryString("mode") = "new" Then
'Order the search results by the date entered into the database decending
strSQL = strSQL & " ORDER By Date_Entered DESC"
'Else order the serch results by the number of click through hits decending
Else
'Order the search results by the number of click through hits decending (most popular sites first)
strSQL = strSQL & " ORDER By Hits DESC"
End If
'Initialise the strAccessDB variable with the name of the Access Database
strAccessDB = "search_engine"
'Create a connection odject
Set adoRec = Server.CreateObject("ADODB.Recordset")
'Open connection to the database driver
strCon = "DRIVER={Microsoft Access Driver (*.mdb)};"
'Open Connection to database
strCon = strCon & "DBQ=" & server.mappath(strAccessDB)
'Query the database with the strSQL statement
adoRec.Open strSQL, strCon, 3
'Set the number of records to display on each page by the constant set at the top of the script
adoRec.PageSize = intRecordsPerPage
'Get the page number record poistion to display from
adoRec.AbsolutePage = intRecordPositionPageNum
'Count the number of records found
intTotalRecordsFound = CInt(adoRec.RecordCount)
'Declarando variáveis
'Definindo caminho do banco
caminho_banco = Server.MapPath("search_engine.mdb")
'Definindo string de conexão
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & caminho_banco
'Criando objeto
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Mode = 3
'Count the number of pages the search results will be displayed on calculated by the PageSize attribute set above
intTotalNumPages = CInt(adoRec.PageCount)
'Calculate the the record number displayed from and to on the page showing
intRecordDisplayFrom = (intRecordPositionPageNum - 1) * intRecordsPerPage + 1
intRecordDisplayedTo = (intRecordPositionPageNum - 1) * intRecordsPerPage + intRecordsPerPage
If intRecordDisplayedTo > intTotalRecordsFound Then intRecordDisplayedTo = intTotalRecordsFound
'Display the HTML table with the results status of the search or what type of search it is
Response.Write vbCrLf & " <table width=""98%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"" bgcolor=""#333399"">"
Response.Write vbCrLf & " <tr>"
'Display that the URL is randomly generated
If Request.QueryString("mode") = "random" Then
Response.Write vbCrLf & " <td> Random URL.</td>"
'Display that we are showing a page of the latest URL's indexed
ElseIf Request.QueryString("mode") = "new" Then
Response.Write vbCrLf & " <td> The " & intRecordsPerPage & " latest URL's Indexed.</td>"
'Display that one of the words entered was to short
ElseIf blnSearchWordLenthOK = False Then
Response.Write vbCrLf & " <td> Searched the web for <b>" & strSearchKeywords & "</b>. One of the words searched is to short.</td>"
'Display that there where no matching records found
ElseIf adoRec.EOF Then
Response.Write vbCrLf & " <td> Searched the web for <b>" & strSearchKeywords & "</b>. Sorry, no results found.</td>"
'Else Search went OK so display how many records found
Else
Response.Write vbCrLf & " <td> Searched the web for <b>" & strSearchKeywords & "</b>. Displaying Results " & intRecordDisplayFrom & " - " & intRecordDisplayedTo & " of " & intTotalRecordsFound & ".</td>"
End If
'Close the HTML table with the search status
Response.Write vbCrLf & " </tr>"
Response.Write vbCrLf & " </table>"
'Display the various results
'HTML table to display the search results or an error if there are no results
Response.Write vbCrLf & " <br>" & vbCrLf
Response.Write vbCrLf & " <table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"">"
Response.Write vbCrLf & " <tr>"
Response.Write vbCrLf & " <td>"
'Display a random URL
If Request.QueryString("mode") = "random" Then
'Randomise system timer
Randomize Timer
'Get a random number between 0 and highest number of records in database
intRandomRecordNumber = Int(RND * intTotalRecordsFound)
'Move to the choosen random record in the database
adoRec.Move intRandomRecordNumber
'Read in the values form the database
intSiteIDNo = CInt(adoRec("SiteIDNo"))
strTitle = adoRec("Title")
strURL = adoRec("URL")
strDescription = adoRec("Description")
intSiteHits = CInt(adoRec("Hits"))
'Display the randon URL details
Response.Write vbCrLf & " <a href=""get_url.asp?SiteID=" & intSiteIDNo & """ target=""_blank"">" & strTitle & "</a>"
Response.Write vbCrLf & " <br>"Response.Write vbCrLf & " <br>"
Response.Write vbCrLf & " <font size=""1"" color=""#00CC99""><i>" & strURL & " - Hits " & intSiteHits & "</i></font>"
Response.Write vbCrLf & " <br><br>"
'Display error message if one of the words is to short
ElseIf blnSearchWordLenthOK = False And NOT Request.QueryString("mode") = "new" Then
'Write HTML displaying the error
Response.Write vbCrLf & " Your Search - <b>" & strSearchKeywords & "</b> - Contained a word with " & intMinuiumSesrchWordLength & " letters or less, this is to short to search."
Response.Write vbCrLf & " <br><br>"Response.Write vbCrLf & " <br>"
Response.Write vbCrLf & " <ul><li>Try longer keywords.<li>Make sure all words are spelled correctly.<li>Try different keywords.<li>Try more general keywords.</ul>"
'If no search results found then show an error message
ElseIf adoRec.EOF Then
'Write HTML displaying the error
Response.Write vbCrLf & " Your Search - <b>" & strSearchKeywords & "</b> - did not match any documents."
Response.Write vbCrLf & " <br><br>"Response.Write vbCrLf & " <br>"
Response.Write vbCrLf & " <ul><li>Make sure all words are spelled correctly.<li>Try different keywords.<li>Try more general keywords.<li>Try fewer keywords.</ul>"
Else
'For....Next Loop to display the results from the database
For intRecordLoopCounter = 1 to intRecordsPerPage
'If there are no records left to display then exit loop
If adoRec.EOF Then Exit For
'Read in the values form the database
intSiteIDNo = CInt(adoRec("SiteIDNo"))
strTitle = adoRec("Title")
strURL = adoRec("URL")
strDescription = adoRec("Description")
intSiteHits = CInt(adoRec("Hits"))
'Display the details of the URLs found
Response.Write vbCrLf & " <a href=""get_url.asp?SiteID=" & intSiteIDNo & """ target=""_blank"">" & strTitle & "</a>"
Response.Write vbCrLf & " <br>"Response.Write vbCrLf & " <br>"
Response.Write vbCrLf & " <font size=""1"" color=""#00CC99""><i>" & strURL & " - Hits " & intSiteHits & "</i></font>"
Response.Write vbCrLf & " <br><br>"
'Move to the next record in the database
adoRec.MoveNext
'Loop back round
Next
End If
'Close the HTML table displaying the results
Response.Write vbCrLf & " </td>"
Response.Write vbCrLf & " </tr>"
Response.Write vbCrLf & " </table>"
'Display an HTML table with links to the other search results if not showing latest 10, a random URL, or not under min word length
If NOT Request.QueryString("mode") = "new" And NOT Request.QueryString("mode") = "random" And blnSearchWordLenthOK = True Then
'Display an HTML table with links to the other search results
Response.Write vbCrLf & " <table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"">"
Response.Write vbCrLf & " <tr>"
Response.Write vbCrLf & " <td>"
Response.Write vbCrLf & " <table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"
Response.Write vbCrLf & " <tr>"
Response.Write vbCrLf & " <td width=""50%"" align=""center"">"
'If there are more pages to display then add a title to the other pages
If intRecordPositionPageNum > 1 or NOT adoRec.EOF Then
Response.Write vbCrLf & " Results Page: "
End If
'If the page number is higher than page 1 then display a back link
If intRecordPositionPageNum > 1 Then
Response.Write vbCrLf & " <a href=""search.aspx?PagePosition=" & intRecordPositionPageNum - 1 & "&search=" & Replace(strSearchKeywords, " ", "+") & "&mode=" & Request.QueryString("mode") &""" target=""_self""><< Prev</a> "
End If
'If there are more pages to display then display links to all the search results pages
If intRecordPositionPageNum > 1 or NOT adoRec.EOF Then
'Loop to diplay a hyper-link to each page in the search results
For intLinkPageNum = 1 to intTotalNumPages
'If the page to be linked to is the page displayed then don't make it a hyper-link
If intLinkPageNum = intRecordPositionPageNum Then
Response.Write vbCrLf & " " & intLinkPageNum
Else
Response.Write vbCrLf & " <a href=""search.aspx?PagePosition=" & intLinkPageNum & "&search=" & Replace(strSearchKeywords, " ", "+") & "&mode=" & Request.QueryString("mode") & """ target=""_self"">" & intLinkPageNum & "</a> "
End If
Next
End If
'If it is Not the End of the search results than display a next link
If NOT adoRec.EOF then
Response.Write vbCrLf & " <a href=""search.aspx?PagePosition=" & intRecordPositionPageNum + 1 & "&search=" & Replace(strSearchKeywords, " ", "+") & "&mode=" & Request.QueryString("mode") & """ target=""_self"">Next >></a>"
End If
'Finsh HTML the table
Response.Write vbCrLf & " </td>"
Response.Write vbCrLf & " </tr>"
Response.Write vbCrLf & " </table>"
Response.Write vbCrLf & " </td>"
Response.Write vbCrLf & " </tr>"
Response.Write vbCrLf & " </table>"
Response.Write vbCrLf & " <br>"
End If
'Close Server Objects
Set adoCon = Nothing
Set adoCmd = Nothing
%>
</form>
<table width="98%" border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF" align="center">
<tr>
<td width="47%"> <a href="add_url_form.htm">Adicionar URL</a></td>
</tr>
</table>
</body>
</html>Carregando comentários...