473,750 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shopping Basket taking extra value -> GLOBAL.asa ?

Fary4u
273 Contributor
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.as p

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

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 1896
Fary4u
273 Contributor
that would be a great if some body repaly on this post thx in advance
Mar 24 '08 #2
jhardman
3,406 Recognized Expert Specialist
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 Contributor
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_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
Mar 27 '08 #4
jhardman
3,406 Recognized Expert Specialist
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

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

Similar topics

0
1672
by: Ian N | last post by:
Hi, I've been working on a PHP Shopping Basket and have hit a problem. I wanted update the DB with the contents of the Array which forms the basket. This isn't a problem, however i'm unsure how i use Relational Tables in MySQL. I have a table called Orders, which stores the CustomersID and also has an OrderID (this is an autoincrement integer)
4
1822
by: Richard Pain | last post by:
OK - I have a shopping basket with data in a database. Once the person has successfully completed their order I want to be able to send them an email with the products ordered roughly in the following format: Product Price Quantity prod1 £6.99 1 prod2 £5.99 2 Postage ...
0
2477
by: TRB_NV | last post by:
I'd been using an Access database based shopping cart, but wanted to change it so that it would use session variables. I have a form that's submitted to a page called addtocart.asp that contains the following information: intProdID -- ProductID strProdName -- Product Name intQuant -- Quantity intProdPrice -- Price productType -- Type of product (ie. Wine, Cheese, etc...)
4
2446
by: Rob Meade | last post by:
Hi all, I need to implement a simplistic shopping basket/checkout thingy... I kinda threw something together, but its not keeping more than one item in the session... I'm basically loading the page, checking to see if there's an "addToBasket" value in the querystring, if there is then I grab the product code (also in the querystring) - now - here's where it seems to be going wrong...
9
2590
by: Rob Meade | last post by:
Hi all, Ok - so I've got the array thing going on, and the session thing going on, and up until now its all been ok. I've got my view basket page which is displaying 3 rows (as an example) - I have an input box on each row enabling the user to update the quantity. If the enter a zero I need to remove the item from the array....
3
1872
by: Samuel Shulman | last post by:
Hi I need to implement a shopping basket for my e-commerce website Scenarios are as follows 1. Website to offer shopping basket for all visitors including those who didn't log 2. Website to offer shopping basket ONLY to those that are logged
11
1998
Fary4u
by: Fary4u | last post by:
Hi i've design the ASP shopping with MS Access database it's working fine there is no problem in LOCALHOST when i upload into the Host Server it's working fine but when u add product into basket it's bring automatically 1 extra product some time 2 or some time 3 i've not made a file called GLOBAL.asa for generate session but if some body add item into the basket it takes OrderID & using Session .
0
1810
by: Shanthini Ganesh | last post by:
hi all. now i m creating shopping cart. i would like to make when the user click the add to basket button, item added visually shown to user. i found one script for this in net.. but i couldnt pass dynamic productid to that addtobasket javascript function. this is my function.. function addToBasket(productId) { if(!shopping_cart_div)shopping_cart_div = document.getElementById('shopping_cart'); if(!flyingDiv){ flyingDiv =...
0
1028
by: jasone | last post by:
Hi all and happy new year! so here's my little problem, im developing a shopping cart for a florist. there will be a traditional shopping cart where the user adds item to basket and so on. i am struggling getting my head round an additional features which will allow the user to create their own bouquet. this will involved a 'flowers_details' tables where the user can select what flowers they want in their basket. when they finish choosing...
3
1173
by: jasone | last post by:
Hi all and happy new year! so here's my little problem, im developing a shopping cart for a florist. there will be a traditional shopping cart where the user adds item to basket and so on. i am struggling getting my head round an additional features which will allow the user to create their own bouquet. this will involved a 'flowers_details' tables where the user can select what flowers they want in their basket. when they finish choosing...
0
9000
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9396
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9339
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4713
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2804
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.