Solved

Subscript out of range error

Posted on 2008-06-18
3
1,594 Views
Last Modified: 2012-05-05
I'm currently building a simple Ecommerce website and when going through the pages that collect the information I keep getting the following error:

Microsoft VBScript runtime  error '800a0009'
Subscript out of range: '[number: 7]'
/site/basket.asp, line 51

Below is the relevant code with line 51 marked, any help is much appreciated.
<%
' Define Constants
CONST CARTPID = 0
CONST CARTPQUANTITY = 1
CONST CARTPNAME = 2
CONST CARTPBOARD = 3
CONST CARTPCOLOUR = 4
CONST CARTPPRICE = 5
CONST CARTPFACE = 6
CONST CARTPREV = 7
 
' Get the Shopping Cart
IF NOT isArray( Session( "cart" ) ) THEN
	DIM localCart( 8,20 )
ELSE
	localCart = Session( "cart" )
END IF
 
' Get Product Information
productID = 		TRIM( Request( "pid" ) )
productQuantity = 	TRIM( Request( "cardQuantity" ) )
productName = 		TRIM( Request( "cardType" ) )
productBoard = 		TRIM( Request( "boardType" ) )
productColour = 	TRIM( Request( "spotColour" ) )
productPrice = 		TRIM( Request( "prodPrice" ) )
productFace =		TRIM( Request( "cardFace" ) )
productReverse =	TRIM( Request( "cardReverse" ) )
 
'Add product to cart
IF productID <> "" THEN
	foundIT = FALSE
	FOR i=0 TO UBOUND( localCart )
		IF localCart( CARTPID, i ) = productID THEN
			localCart( CARTPQUANTITY, i ) = localCart( CARTPQUANTITY, i )
			foundIT = TRUE
			EXIT FOR
		END IF
	NEXT
	IF NOT foundIT THEN
		FOR i = 0 TO UBOUND( localCart, 2 )
			IF localCart( CARTPID, i ) = "" THEN
				localCart( CARTPID, i ) = productID
				localCart( CARTPQUANTITY, i ) = productQuantity
				localCart( CARTPNAME, i ) = productName
				localCart( CARTPBOARD, i ) = productBoard
				localCart( CARTPCOLOUR, i ) = productColour
				localCart( CARTPPRICE, i ) = productPrice
				localCart( CARTPFACE, i ) = productFace
		*line 51*       localCart( CARTPREV, i ) = productReverse
				EXIT FOR
			END IF
		NEXT
	END IF
END IF
%>

Open in new window

0
Comment
Question by:dreamworks_studio
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Expert Comment

by:512Thz
ID: 21813912
Try the folowing

If it produce the mesage "The cart had the wrong dim"

It means that your cart was not dimensionned at 8 (but 7)
IF NOT isArray( Session( "cart" ) ) THEN
	DIM localCart( 8,20 )
ELSE
	localCart = Session( "cart" )
END IF
 
IF Uboud(localCart, 1) < 8 Thne
  REDIM  localCart( 8,20 )
  Response.Write("The cart had the wrong dimension!!!")
END IF
 
.... etc  ...

Open in new window

0
 
LVL 4

Accepted Solution

by:
512Thz earned 500 total points
ID: 21813949
Oups...
IF Uboud(localCart, 1) < 7 Then
0
 
LVL 1

Author Closing Comment

by:dreamworks_studio
ID: 31468397
I guess that means the cart had the wrong dimension! I was sure I'd set it right but still learning this so many thanks for your help!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Technology Resume 7 88
How can I improve my website to a higher score via webometrics rules? 4 96
Display if field is NOT "" or NOT null 6 36
Html split(text) Part2 6 41
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question