D
David
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>
»</i></span></a>"
next
%>
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>
»</i></span></a>"
next
%>