Click to See Complete Forum and Search --> : a poor little girl, lost in the terrifying asp world... ;)


Ness_du_Frat
08-16-2004, 03:43 PM
Hello everybody !!
First of all, I don't know ANYTHING in asp. Normaly, I work with javascript and html only...
But... ( there's always a but... )
I'm making a website, in which I need a search engine. The server the site is on doesn't support php ( yet ), so I have to find something else.
I thought of the Google search engine, but after trying it, I noticed that I couldn't use it for what I want, as it returns only the pages with a meta corresponding to the query.
The website I'm making is for a university, and it contains lots of informations, concerning a lot of different subjects.
I want something capable of browsing through the pages, and searching for a particular string, and returning the reference of the pages containing the words we searched for...
Now, it comes to asp.
I found a asp script ( or whatever it's called ) which does exactly what I want, but I can't seem to make it work... :(
Here is the page where I found it (http://www.4guysfromrolla.com/webtech/102499-1.shtml#postadlink)
I put it on my website, and when I use it, it returns only that :
Search Results for
and a blank page. I think there must be a connection problem between the search.asp page, and textsearch.asp.
There was a small comment mistake in the code, I corrected it, so it's not that...
Can you help me, please ? I'm really dispaired... And sorry for my weird english, I'm French... ;)

lmf232s
08-16-2004, 06:17 PM
I downloaded the code and it works fine for me. You need two pages
Search.asp
TextSearch.asp


Search.asp

<HTML>
<BODY>
<FORM METHOD=POST ACTION="TextSearch.asp">
Enter text to search for:
<INPUT TYPE=TEXT NAME=SearchText>
<P>
<INPUT TYPE=SUBMIT VALUE="Begin Search!">
</FORM>
</BODY>
</HTML>


TextSearch.asp

<HTML><BODY>
<B>Search Results for <%=Request("SearchText")%></B><BR>

<%
Const fsoForReading = 1

Dim strSearchText
strSearchText = Request("SearchText")

'Now, we want to search all of the files
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")


Dim objFolder
Set objFolder = objFSO.GetFolder(Server.MapPath("/"))

Dim objFile, objTextStream, strFileContents, bolFileFound
bolFileFound = False

For Each objFile in objFolder.Files
If Response.IsClientConnected then
Set objTextStream = objFSO.OpenTextFile(objFile.Path,fsoForReading)

strFileContents = objTextStream.ReadAll

If InStr(1,strFileContents,strSearchText,1) then
Response.Write "<LI><A HREF=""/" & objFile.Name & _
""">" & objFile.Name & "</A><BR>"

Response.Write "<a href=""Search.asp"">Search</a><br>"

bolFileFound = True
End If

objTextStream.Close
End If
Next

if Not bolFileFound then Response.Write "No matches found..."

Set objTextStream = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>

</BODY></HTML>


I did notice that it put a <XML> tag infront of the <html> tag and at the end on both pages. This made it not run correctly. You must remove those tags.
Cut and past my code and it should work.
Pretty cool little script as well, I like it way it works,
and will incorporate it into my site.

Thanks.

Let me know if you have any problems with this.

Ness_du_Frat
08-17-2004, 01:02 AM
it still doesn't work... :(
I type in my search query, and it returns only :
search results for
and nothing else...
Do I need to put the 2 files in a special folder ? Do I need an asp module on my server ?

lmf232s
08-17-2004, 10:04 AM
Not sure. Maybe ASP is not supported by your server.

The script seems to run fine and ruturned rusults for me based on what i had search by so i dont think it has anything to do with the code. It does not have to be in a special folder.

Dont Know.
Not sure.

Ness_du_Frat
08-17-2004, 11:38 AM
I dropped it, 'cause it really wasn't working on the server. i think my server didn't support ASP. As a matter of fact, as it doesn't support anything, I searched for something in Javascript. At least, THAT is supported...
And here is what I've found...
Zoom search engine (http://www.wrensoft.com/zoom/)
A fully customizable seach engine, free, no adds, able to function in asp, php, cgi and javascript...
I thought it might interest you... :)
And thanks for your answers !!!
NesS