Subscript out of range: 'ticker' ?????

Discussion in 'ASP General' started by David, Mar 1, 2006.

  1. David

    David Guest

    Hi, I have the following asp in my page, but I keep getting the
    following error

    Microsoft VBScript runtime error '800a0009'

    Subscript out of range: 'ticker'

    Please can you help me ?. Here is the page code I have so far:
    ---------------------------------


    <%
    Randomize
    R=clng(1E6*rnd)
    F=1+clng(1E3*rnd)

    Dim RS_rand
    Set RS_rand = Server.CreateObject("ADODB.Recordset")
    RS_rand.ActiveConnection = conn_string
    RS_rand.Source = "SELECT TOP 2 * FROM products WHERE product_New = 1
    ORDER BY ((product_ID * " & F & "+" & R & ")Mod 1000);"
    RS_rand.CursorType = 0
    RS_rand.CursorLocation = 2
    RS_rand.LockType = 1
    RS_rand.Open()

    Dim prodArray(3,2)
    ID_CODE = 0
    THUMB_CODE = 1
    DESC_CODE = 2
    URL_CODE = 3

    ticker = -1

    If NOT (RS_rand.EOF) OR NOT(RS_rand.BOF) then
    While NOT RS_rand.EOF
    ticker = ticker + 1

    prodArray(ID_CODE, ticker) = RS_rand("product_ID")
    prodArray(THUMB_CODE,ticker) = RS_rand("product_Thumb")

    p_desc = RS_rand("product_Description_2")
    if IsNull(p_desc) then
    p_desc = RS_rand("product_Description")
    end if
    if (Len(p_desc) >= 60 ) then
    space_pos = InStr(120, p_desc, " ") - 1
    p_desc = Left(p_desc, space_pos) & "..."
    end if
    prodArray(DESC_CODE,ticker) = p_desc

    Set RS_URL = Server.CreateObject("ADODB.Recordset")
    RS_URL.ActiveConnection = conn_string
    SQL = "SELECT category_URL FROM categories WHERE category_ID = " &
    RS_rand("category_ID")
    RS_URL.Source = SQL
    RS_URL.Open()

    prodArray(URL_CODE,ticker) = RS_URL("category_URL")

    RS_URL.Close()
    Set RS_URL = Nothing
    RS_rand.MoveNext
    WEnd
    End If

    RS_rand.Close()
    Set RS_rand = Nothing

    ' Super. We have the info in our array. Now let's make the html:
    Dim RandomBox(3)
    for i = 0 to ticker step 1
    RandomBox(i) = "<div class=""imgholder""><img
    src=""../product-images/" & prodArray(THUMB_CODE,i) & """ alt=""""
    width=""125"" /></div>"
    RandomBox(i) = RandomBox(i) & "<a href=""../" & prodArray(URL_CODE,i)
    & "/product.asp?ID=" & prodArray(ID_CODE,i) & """>" &
    prodArray(DESC_CODE, i) & " <span class=""obvious"">read more<i>
    &raquo;</i></span></a>"
    next

    %>

    ------------------------------

    Thanks so much

    David
     
    David, Mar 1, 2006
    #1
    1. Advertising

  2. "David" <> wrote in message
    news:...
    > Hi, I have the following asp in my page, but I keep getting the
    > following error
    >
    > Microsoft VBScript runtime error '800a0009'
    >
    > Subscript out of range: 'ticker'
    >
    > Please can you help me ?. Here is the page code I have so far:
    > ---------------------------------
    >
    >

    <snip/>
    >


    Can't see anything obvious. Which Database are you using? It looks like
    you are doing a lot of work in Script that you should be doing in SQL
    instead resulting a much simpler ASP.
     
    Anthony Jones, Mar 2, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Delorme

    out of range array subscript

    Richard Delorme, May 3, 2004, in forum: C Programming
    Replies:
    5
    Views:
    499
    Chris Torek
    May 15, 2004
  2. Andy
    Replies:
    6
    Views:
    760
    James Kanze
    May 11, 2007
  3. Han
    Replies:
    4
    Views:
    8,121
  4. yogi_bear_79
    Replies:
    11
    Views:
    990
    James Kanze
    Mar 16, 2008
  5. Lukelrc

    Subscript out of range error

    Lukelrc, May 19, 2004, in forum: ASP General
    Replies:
    2
    Views:
    229
    Mark Schupp
    May 19, 2004
Loading...

Share This Page