asp, page through.

They have: 34 posts

Joined: Feb 2002

Yo, I'm having problems with my search page. If you do a sample search it takes you to a page full of results. Then if you click to view any of the next pages you get the following error.
Microsoft VBScript runtime error '800a0009'

Subscript out of range: '[number: 0]'

/x/page.asp, line 228

Code- this is from line 217 to 239------------------------------------------------------->
string1=searchit

if not instr(searchit,"OR") and not instr(searchit,"AND") and not instr(searchit,"+") then
if request("type")="exact" then
string1=searchit
searchitt="SELECT * from " & dbase & " where (News LIKE '%" & trim(string1) & "%'"
searchitt=searchitt&" or Title LIKE '%" & trim(string1) & "%' )"
else
arr="yes"
searchstr=split (searchit," ")
maxcounter=ubound(searchstr)
string1=searchstr(0) //############ line 228

searchitt="SELECT * from " & dbase & " where (News LIKE '%" & trim(searchstr(0)) & "%'"
searchitt= searchitt&"or Title LIKE '%" & trim(searchstr(0)) & "%' )"
FOR counter=1 TO maxcounter
this=searchstr(counter)
searchitt=searchitt & " and (News LIKE '%" & trim(this) & "%'"
searchitt=searchitt & " or Title LIKE '%" & trim(this) & "%' )"
NEXT
mySQL=searchitt
end if
end if

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

It sounds like searchstr isn't an array. Add this line before line 228 to verify that it is an array.

If IsArray(searchstr) Then Response.Write "It's an array!" Else Response.Write "Nope, it's not an array!"

You will generate subscript errors when you try enumerating a string (not an array).

PJ | Are we there yet?
pjboettcher.com

They have: 34 posts

Joined: Feb 2002

"It's an array!"

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

Hmm, if it's an array than that means it must not be starting at 0 for some reason. Did you try starting at another number like 1 or something?

Maybe change line 228 to:

string1=searchstr(LBound(searchstr))

PJ | Are we there yet?
pjboettcher.com

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.