468,289 Members | 1,787 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,289 developers. It's quick & easy.

Shopping Basket taking extra value -> GLOBAL.asa ?

Fary4u
273 100+
Hi

for the last few months i've just stuck in 1 error & i don't know how to figer it out
could any body find out where is the problem gonna be ?

it's working fine but when u add product into basket it's bring automatically 1 extra product some time 2 or some time it's working fine i think so problem with GLOBAL.asa File that's not generating proper session variable

GLOBAL.asa
Expand|Select|Wrap|Line Numbers
  1. Sub Application_OnStart
  2.  
  3. CStr = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & pPath & ";" & "JET OLEDB:Database Password=foo"
  4.  
  5.     Application("visits") = 0
  6.     Application("Active") = 0
  7.  
  8.     set Conn = Server.CreateObject("ADODB.Connection")
  9.     Conn.Open CStr
  10.  
  11.     set rsMaxOrder = Conn.Execute("select orderID from" _
  12.     & " orders " & "order by orderID desc")
  13.     if rsMaxOrder.EOF then
  14.         Application("orderID") = 1
  15.     else
  16.         Application("orderID") = rsMaxOrder("orderID") + 1
  17.     end if
  18.     rsMaxOrder.Close
  19.     set rsMaxOrder = Nothing
  20.     Conn.Close
  21.     set Conn = Nothing    
  22. End Sub
  23.  
  24. Sub Session_OnStart
  25.     Session("Start") = Now
  26.     session("uname")=""
  27.     Application.lock
  28.     Application("visits") = Application("visits") + 1
  29.     intTotal_visitors = Application("visits")
  30.     Application.unlock
  31.     Session("VisitorID") = intTotal_visitors
  32.  
  33.     Application.lock
  34.     Application("Active") = Application("Active") + 1
  35.     Application.unlock
  36. End Sub
  37.  
  38. Sub Session_OnEnd
  39.     Application.lock
  40.     Application("Active") = Application("Active") - 1
  41.     Application.unlock
  42.  
  43. session("uname")=""
  44.     If Not Application(Session.SessionID) = "" Then
  45.         Application(Session.SessionID) = ""
  46.     End If
  47.  
  48. End Sub
  49.  
---------------------------------------------------------

Before i add product into the basket there is no item shown into the basket
But when i add product into the basket & after that review then it's create the problem .

There is 2 files

1 - add_to_cart.asp
2 - review_order.asp

__________________________________________________ _______
Expand|Select|Wrap|Line Numbers
  1. <!-- #include file="database.asp" -->
  2. <!-- #include file="adovbs.inc" -->
  3. <%   
  4.  
  5. Sub CreateNewOrder()
  6.         Application.lock
  7.         if Application("orderID") = "" then
  8.             Application("orderID") = 1
  9.         end if
  10.  
  11.        intOrderID = Application("orderID")
  12.        Session("orderID") = intOrderID
  13.        Conn.Execute("INSERT INTO orders " _
  14.         & " (orderID, status) values " _
  15.         & " ("&intOrderID&", 'OPEN')")
  16.  
  17.         Application("orderID") = Application("orderID") + 1
  18.        Application.Unlock
  19.     End Sub
  20.  
  21.     Sub AddToOrder(nOrderID, nProductID, nQuant)
  22.         sqlText = "INSERT INTO itemsOrdered " _
  23.             & " (orderID, productID, quantity) values " _ 
  24.             & " ('"&nOrderID&"', '"&nProductID&"', '"&nQuant&"')"
  25.         Conn.Execute(sqlText)
  26.  
  27.     End Sub
  28.  
  29.     'Main program 
  30.     intProdID = Request.form("intProdID")
  31.     intQuant = Request.form("intQuant")
  32.  
  33.     set Conn = Server.CreateObject("ADODB.Connection")
  34.     Conn.Open ConString
  35.  
  36.     intOrderID = cstr(Session("orderID"))
  37.     if intOrderID = "" then
  38.        CreateNewOrder
  39.     end if
  40.  
  41.     sqlText = "SELECT * FROM itemsOrdered WHERE orderID =" & intOrderID & "AND productID =" & intProdID
  42.     set rsOrder = Conn.Execute(sqlText)
  43.  
  44.     if rsOrder.EOF then
  45.         txtInfo = "This item has been added to your order."  
  46.         AddToOrder intOrderID, intProdID, intQuant
  47.     else
  48.         txtInfo = "This item is already in your cart."
  49.     end if
  50.  
  51. %>
  52. <html>
  53. <head>
  54. </head>
  55. <body>
  56. <a href="review_Order.asp">review order</a>
  57. <%
  58.     Conn.Close
  59.     set Conn = Nothing
  60. %>
  61.  
  62. </font></td></tr></table> </body></html>
__________________________________________________ ______

2 - review_order.asp

Expand|Select|Wrap|Line Numbers
  1. <%@ Language=VBScript %>
  2. <% pageTitle = "Review Order" %>
  3. <!-- #include file="database.asp" -->
  4. <!-- #include file="adovbs.inc" -->
  5. <html>
  6. <head>
  7. </head>
  8. <body>
  9. <%
  10.     set Conn = Server.CreateObject("ADODB.Connection")
  11.     Conn.Open ConString
  12.  
  13.     if cstr(Session("orderID")) = "" then
  14.         Response.Write "There is no current order." & "<br>"
  15.     else
  16.         intOrderID = cstr(Session("orderID"))
  17.  
  18.         sqlText = "select products.productID, productName, " _
  19.             & "productPrice, quantity from products, " _
  20.             & "itemsOrdered where " _
  21.             & "products.productID = itemsOrdered.productID "_
  22.             & "and itemsOrdered.orderID = " & intOrderID
  23. %>
  24. <%      
  25. set rsReview = Conn.Execute(sqlText)
  26. while not rsReview.EOF  
  27.       intProdID = rsReview("productID")
  28.       strProdName = rsReview("productName")
  29.       intProdPrice = rsReview("productPrice")
  30.       intQuant = rsReview("quantity")
  31.       intTotal = intTotal + (intQuant * intProdPrice)
  32. %>
  33.  
  34. <input name="quant<%= intProdID %>" value=" <%=intQuant%>"><br>
  35. <%= strProdName %> <%= formatNumber(intProdPrice, 2) %>
  36.  
  37. <%               
  38. rsReview.MoveNext
  39. wend
  40.  
  41. rsReview.Close
  42. set rsReview = Nothing
  43. %>        
  44. <input type="submit" name="control" value="Update Order">
  45. <input type="submit" name="control" value="Go To Check-Out">
  46. <%
  47.     end if
  48.  
  49.     Conn.Close
  50.     set Conn = Nothing
  51. %>
  52. </body></html>
Thanks in advance
Mar 21 '08 #1
4 1727
Fary4u
273 100+
that would be a great if some body repaly on this post thx in advance
Mar 24 '08 #2
jhardman
3,405 Expert 2GB
I spent a couple hours working on this last night, and I couldn't get your issue to come up. I think the problem might be how you determine the order number when the application starts. Instead of just assigning the number from the application variables, I think you should pull the last number from the db, and add one. Let me know if this helps.

Jared
Mar 27 '08 #3
Fary4u
273 100+
Hi 1st fo all thank for you kindly reply
i'm attatch my code so you can view where is the problem
following link having the code contains zip file

http://www.insidee.net/global.zip

Can you plz take a look following files with having any error

1-global.asa
2-addToCart.asp
3-reviewOrder.asp

the attatch file contains all my file but i think so i forget to put code in global.asa file

Sub Application_OnEnd
' ? ? ? ? ? ?
End Sub

do i have to ?
i'm realy appricate about you concern & you time
if you plz take a look 1 more time about my code i realy gr8 full

if there is any question feel free to send msg

Regards
Fary
Mar 27 '08 #4
jhardman
3,405 Expert 2GB
I don't think I'll be able to see the problem, I already tried. What I would do to find the problem is to track the orderID. Print it to the page (response.write) before and after the problem is noticeable, see if you are getting the order Id you expect, and see if anything happens to that number.

Jared
Mar 28 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Ian N | last post: by
reply views Thread by TRB_NV | last post: by
4 posts views Thread by Rob Meade | last post: by
3 posts views Thread by Samuel Shulman | last post: by
reply views Thread by jasone | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.