Hi All,
Can someone please help me...
For my Uni project i'm comparing PHP to ASP... I've written a simple e-commerce site in PHP with user log-in area, and shopping cart... etc... To do the shopping cart I simply stored an associative array in a session variable, with product id as the key, and quantity as the value... And it works a treat...
Which brings me to my ASP version... I've replicated everything i've done in the PHP site perfectly except for one section... The shopping cart... The only thing i can think that is close to an associative array in ASP is the Dictionary Object.
Which is where my problems begin.
I am starting my object in the global.asa as follows:
<object runat=server scope=session id=basket progid="scripting.dictionary"></object>
Then using the different methods on it.. through my shopping cart functions... One function in particular:
function addItem(prod_id, quantity)
basket.item(prod_id) = quantity
end function
This passes in a product id and a quantity, and sets a dictionary key accordingly... if that key exists it should change the value to the new 'quantity', and if it doesn't exist it should set a new key with that value (according to the books)... looks simply enough, but isn't working...
If i add 1 item of a particular product, it adds it fine... If i then try to change it to have a quantity of 3, it seems to create another row, of the same product, but with 3 as its quantity....
i.e
prod_id quantity
4 1
then change the amount... and the cart shows...
prod_id quantity
4 1
4 3
And my delete_item function.....
function deleteItem(prod_id)
basket.remove(prod_id)
end function
returns this error...
Error Type:
Microsoft VBScript runtime (0x800A802B)
Element not found
/ASP/basketfunctions.asp, line 7
Has anyone had this problem before... PLEASE HELP ME!!!!!
Can someone please help me...
For my Uni project i'm comparing PHP to ASP... I've written a simple e-commerce site in PHP with user log-in area, and shopping cart... etc... To do the shopping cart I simply stored an associative array in a session variable, with product id as the key, and quantity as the value... And it works a treat...
Which brings me to my ASP version... I've replicated everything i've done in the PHP site perfectly except for one section... The shopping cart... The only thing i can think that is close to an associative array in ASP is the Dictionary Object.
Which is where my problems begin.
I am starting my object in the global.asa as follows:
<object runat=server scope=session id=basket progid="scripting.dictionary"></object>
Then using the different methods on it.. through my shopping cart functions... One function in particular:
function addItem(prod_id, quantity)
basket.item(prod_id) = quantity
end function
This passes in a product id and a quantity, and sets a dictionary key accordingly... if that key exists it should change the value to the new 'quantity', and if it doesn't exist it should set a new key with that value (according to the books)... looks simply enough, but isn't working...
If i add 1 item of a particular product, it adds it fine... If i then try to change it to have a quantity of 3, it seems to create another row, of the same product, but with 3 as its quantity....
i.e
prod_id quantity
4 1
then change the amount... and the cart shows...
prod_id quantity
4 1
4 3
And my delete_item function.....
function deleteItem(prod_id)
basket.remove(prod_id)
end function
returns this error...
Error Type:
Microsoft VBScript runtime (0x800A802B)
Element not found
/ASP/basketfunctions.asp, line 7
Has anyone had this problem before... PLEASE HELP ME!!!!!