Shopping Basket taking extra value -> GLOBAL.asa ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fary4u
    Contributor
    • Jul 2007
    • 273

    Shopping Basket taking extra value -> GLOBAL.asa ?

    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
    [code=asp]
    Sub Application_OnS tart

    CStr = "PROVIDER=MICRO SOFT.JET.OLEDB. 4.0;DATA SOURCE=" & pPath & ";" & "JET OLEDB:Database Password=foo"

    Application("vi sits") = 0
    Application("Ac tive") = 0

    set Conn = Server.CreateOb ject("ADODB.Con nection")
    Conn.Open CStr

    set rsMaxOrder = Conn.Execute("s elect orderID from" _
    & " orders " & "order by orderID desc")
    if rsMaxOrder.EOF then
    Application("or derID") = 1
    else
    Application("or derID") = rsMaxOrder("ord erID") + 1
    end if
    rsMaxOrder.Clos e
    set rsMaxOrder = Nothing
    Conn.Close
    set Conn = Nothing
    End Sub

    Sub Session_OnStart
    Session("Start" ) = Now
    session("uname" )=""
    Application.loc k
    Application("vi sits") = Application("vi sits") + 1
    intTotal_visito rs = Application("vi sits")
    Application.unl ock
    Session("Visito rID") = intTotal_visito rs

    Application.loc k
    Application("Ac tive") = Application("Ac tive") + 1
    Application.unl ock
    End Sub

    Sub Session_OnEnd
    Application.loc k
    Application("Ac tive") = Application("Ac tive") - 1
    Application.unl ock

    session("uname" )=""
    If Not Application(Ses sion.SessionID) = "" Then
    Application(Ses sion.SessionID) = ""
    End If

    End Sub
    [/code]

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

    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.as p

    _______________ _______________ _______________ ____________
    [code=asp]
    <!-- #include file="database. asp" -->
    <!-- #include file="adovbs.in c" -->
    <%

    Sub CreateNewOrder( )
    Application.loc k
    if Application("or derID") = "" then
    Application("or derID") = 1
    end if

    intOrderID = Application("or derID")
    Session("orderI D") = intOrderID
    Conn.Execute("I NSERT INTO orders " _
    & " (orderID, status) values " _
    & " ("&intOrderID&" , 'OPEN')")

    Application("or derID") = Application("or derID") + 1
    Application.Unl ock
    End Sub

    Sub AddToOrder(nOrd erID, nProductID, nQuant)
    sqlText = "INSERT INTO itemsOrdered " _
    & " (orderID, productID, quantity) values " _
    & " ('"&nOrderID&"' , '"&nProductID&" ', '"&nQuant&"' )"
    Conn.Execute(sq lText)

    End Sub

    'Main program
    intProdID = Request.form("i ntProdID")
    intQuant = Request.form("i ntQuant")

    set Conn = Server.CreateOb ject("ADODB.Con nection")
    Conn.Open ConString

    intOrderID = cstr(Session("o rderID"))
    if intOrderID = "" then
    CreateNewOrder
    end if

    sqlText = "SELECT * FROM itemsOrdered WHERE orderID =" & intOrderID & "AND productID =" & intProdID
    set rsOrder = Conn.Execute(sq lText)

    if rsOrder.EOF then
    txtInfo = "This item has been added to your order."
    AddToOrder intOrderID, intProdID, intQuant
    else
    txtInfo = "This item is already in your cart."
    end if

    %>
    <html>
    <head>
    </head>
    <body>
    <a href="review_Or der.asp">review order</a>
    <%
    Conn.Close
    set Conn = Nothing
    %>

    </font></td></tr></table> </body></html>[/code]
    _______________ _______________ _______________ ___________

    2 - review_order.as p

    [code=asp]
    <%@ Language=VBScri pt %>
    <% pageTitle = "Review Order" %>
    <!-- #include file="database. asp" -->
    <!-- #include file="adovbs.in c" -->
    <html>
    <head>
    </head>
    <body>
    <%
    set Conn = Server.CreateOb ject("ADODB.Con nection")
    Conn.Open ConString

    if cstr(Session("o rderID")) = "" then
    Response.Write "There is no current order." & "<br>"
    else
    intOrderID = cstr(Session("o rderID"))

    sqlText = "select products.produc tID, productName, " _
    & "productPri ce, quantity from products, " _
    & "itemsOrder ed where " _
    & "products.produ ctID = itemsOrdered.pr oductID "_
    & "and itemsOrdered.or derID = " & intOrderID
    %>
    <%
    set rsReview = Conn.Execute(sq lText)
    while not rsReview.EOF
    intProdID = rsReview("produ ctID")
    strProdName = rsReview("produ ctName")
    intProdPrice = rsReview("produ ctPrice")
    intQuant = rsReview("quant ity")
    intTotal = intTotal + (intQuant * intProdPrice)
    %>

    <input name="quant<%= intProdID %>" value=" <%=intQuant%>"> <br>
    <%= strProdName %> £<%= formatNumber(in tProdPrice, 2) %>

    <%
    rsReview.MoveNe xt
    wend

    rsReview.Close
    set rsReview = Nothing
    %>
    <input type="submit" name="control" value="Update Order">
    <input type="submit" name="control" value="Go To Check-Out">
    <%
    end if

    Conn.Close
    set Conn = Nothing
    %>
    </body></html>[/code]
    Thanks in advance
  • Fary4u
    Contributor
    • Jul 2007
    • 273

    #2
    that would be a great if some body repaly on this post thx in advance

    Comment

    • jhardman
      Recognized Expert Specialist
      • Jan 2007
      • 3405

      #3
      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

      Comment

      • Fary4u
        Contributor
        • Jul 2007
        • 273

        #4
        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



        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_OnE nd
        ' ? ? ? ? ? ?
        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

        Comment

        • jhardman
          Recognized Expert Specialist
          • Jan 2007
          • 3405

          #5
          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

          Comment

          Working...