Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Access Error - Urgent Help Needed

Status
Not open for further replies.

chinedu

Technical User
Mar 7, 2002
241
US
I created a shopping cart program.
When I tested it, I got this error message:

Error
We noticed you do not accept cookies. Please enable cookies to shop.

I resolved it by going to iis and selecting Application Name ... Create.

Once we feel the application is ready to be deployed, we deployed it to the web to be hosted by a web hosting company.
Right now, we are experiencing the same problem.
The web hosting company doesn't feel there is anything they can do to fix it and I am at a loss as to how to fix it.

The user is wants to start using their app.

Can anyone suggest a possible resolution, please!

Thanks in advance
 
Sorry,
I forgot to post the error I am getting.

Here it is:

Error
We noticed you do not accept cookies. Please enable cookies to shop.
 
How do I get rid of cookies being required by shopping carts?

Please help!
 
no idea. You wrote it

I created a shopping cart program.

hopefully you'll know what you put in it.



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
sorry,
I didn't mean for it to sound stupid but unless I coded something other than was I was asked to code, here is the code that is spitting the error message.

Code:
If scartItem = "" Then
	Response.Redirect "error.asp?msg=" & Server.URLEncode ("We noticed you do not accept cookies. Please enable cookies to shop.")
else
	if quantity <> "" AND quantity < 1 then
		Response.Redirect "error.asp?msg=" & Server.URLEncode ("Please enter at least 1 as number of items you wish to order.")
	end if
End If

I actually to say something like:
Code:
If scartItem = "" Then
response.redirect "error.asp?msg=" & Server.URLEncode ("Make sure cart is not empty")

So when I asked the question in my last thread,
I was trying to say, I don't recall checking for cookies in any of the pages.

 
in your code above you are checking if scartItem is empty which it always will be until someone puts something into the basket/cart.

The only time you should check this is when a customer goes to add an item an cookies are disabled.

if you need to check if cookies are accepted run a "silent" check and set a flag then you can decide to use session variables or a temporary table.

this function will test for a test value being true (it will be false the first time or if cookies are not allowed) If false it tries to write the test value and returns true or false depending on the result

Code:
function CheckCookie()
' check if test value = true 
CheckCookie = false
if request.cookies("test") <> true then
response.cookies("test") = true
CheckCookie = request.cookies("test")
end if
end function

Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Chris,
From your last post, you seem to suggest ( I apologize if I am wrong) that session variables may be responsible for the error I am getting.

Again I apologize if I made a wrong assumption.

I didn't think session variables, not cookies would be causing such a problem.

But if indeed it is causing it, could this code below be causing it?

If yes, can help resolve, pleeeeeeeeeeease, I am begging!

Code:
'generates session variables with order items
Dim prodid, quantity, arrCart, scartItem
prodid = Request.Form("fproductid")
quantity = Request.Form("fquantity")
arrCart = Session("MyCart")
scartItem = Session("cartItem")

If scartItem = "" Then
	Response.Redirect "error.asp?msg=" & Server.URLEncode ("We noticed you do not accept cookies. Please enable cookies to shop.")
else
	if quantity <> "" AND quantity < 1 then
		Response.Redirect "error.asp?msg=" & Server.URLEncode ("Please enter at least 1 as number of items you wish to order.")
	end if
End If

If prodid <> "" Then
	call addToCart()
Else
	Dim strAction
	strAction = UCase(Left(Request.Form("action"),5))
	Select Case strAction
	Case "CONTI"	 	'continue shopping
		Response.Redirect "Default.asp"
	Case "RECAL"		'recalculate
		call recalculateCart()
	Case "PROCE" 		'proceed to checkout
		Response.Redirect "customer.asp"
	End Select
'end if for updating or inserting new item in Cart
End If

sub addToCart()
If scartItem < maxCartItems Then
		scartItem = scartItem + 1
	End If
	Session("cartItem") = scartItem
	dim rsItem, sqlProductInfo
	sqlProductInfo = "SELECT * FROM products WHERE (products.catalogID=" & prodid & ")"

	'open connection - returns dbc as Active connection
	call openConn()
	Set rsItem = Server.CreateObject("ADODB.Recordset")
	rsItem.Open sqlProductInfo, dbc, adOpenForwardOnly,adLockReadOnly,adCmdText
	If Not rsItem.EOF Then
		arrCart(cProductid,scartItem) = rsItem("catalogID")
		arrCart(cProductCode,scartItem) = rsItem("ccode")
		arrCart(cProductname,scartItem) = rsItem("cname")
		arrCart(cQuantity,scartItem) = CInt(quantity)
		arrCart(cUnitPrice,scartItem) = rsItem("cprice")
		Session("MyCart") = arrCart
	End If
	rsItem.Close
	set rsItem = nothing
	call closeConn()
end sub


sub recalculateCart()
For i = 1 To scartItem
	Dim tquantity
	tquantity = Request.Form("quantity" & Cstr(i))
	if isempty(tquantity) OR (tquantity = "") then
		tquantity = 0
	elseif (tquantity < 0) OR (isnumeric(tquantity)=false) then
		tquantity = 0
	end if
	arrCart(cQuantity,i) = CInt(tquantity)
Next
	'make temp array and set it empty
	ReDim temparrcart(UBound(arrCart,1),UBound(arrCart,2))
	Dim tempItems
	tempItems = 0
	For x = 1 to UBound(arrCart,1)
		For y = 1 to UBound(arrCart,2)
			temparrCart(x,y) = ""
		Next
	Next
	For i = 1 to scartItem
		confirm = Request.Form("selected" & CStr(i))
		zeroQuantity = arrCart(cQuantity,i)
		If confirm <> "" and  zeroQuantity > 0 Then
			tempItems = tempItems +1
			For x = 1 to UBound(arrCart,1)
				temparrCart(x,tempItems) = arrCart(x,i)
			Next
		End If
	Next
	For x = 1 to UBound(arrCart,1)
		For y = 1 to UBound(arrCart,2)
			arrCart(x,y) = temparrCart(x,y)
		Next
	Next
	scartItem = tempItems

	Session("cartItem") = scartItem
	Session("MyCart") = arrCart

end sub
 
what I'm saying is that this

Code:
scartItem = Session("cartItem")

will always be empty the first time the page is opened therefore will always goto error. it will only go past this if there is already something in the session variable and assuming this is your add to cart function you can't add anything until there is something added. bit of a chicken and egg situation.

you need a check other than seeing if an item has been added. Maybe use another session variable set to true when the first item has been added.

Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
I didn't envision this when I implmented this functionality.

Chris,
How much modification do I need to make to the function you posted above to help me resolve this issue?

Please accept my thanks for all your help.
 
Are you joking ?

>>>> I didn't envision this when I implmented this functionality.

You didn't envisage a "shopping cart" being empty when someone first visited the page ?

How about just coding that fact that "If the shopping cart is empty on this page, then they must have not chosen anything yet, so DON'T throw an error, just let them continue" ???

--------------------------------------------------
Free Database Connection Pooling Software
 
With all due respect, if you feel you can help, sedj, please do so.
It is already hard as it is.
Being satiristic isn't helping me here at all.


I did check for empty cart, if you look at the code I posted earlier.
I just didn't expect that I would be having a cookie issue.

I used session variable with the intent of carrying values from page to page for the duration of the process.

Anything that would help solve this problem from you, Chris or anyone else would be greatly appreciated.
 
Well, I've never touched ASP in my life, but from a quick look at :


it seems that your code :

Code:
scartItem = Session("cartItem")

If scartItem = "" Then
    Response.Redirect "error.asp?msg=" & Server.URLEncode ("We noticed you do not accept cookies. Please enable cookies to shop.")

does NOT check for the availability if cookies, but asks "Is there a session object called cartItem ? If there is not, then make some error about cookies".

Maybe I'm missing something ???



--------------------------------------------------
Free Database Connection Pooling Software
 
Code:
function CheckSession()
' check if test value = true 
CheckSession= false
if session("test") <> true then
session("test") = true
CheckSession= session("test")
end if
end function

the code could then become;
Code:
if not CheckSession then
 strMessage = "Cookies must be enabled to use the shopping cart features"
end if
then display the message somewhere on the browser window.

get rid of the whole idea of redirecting to a page just because there was no quantity entered make sure the code puts a default of 1 into the quantity box when the page is displayed. And when you check quantity for errors set a flag and display an error on the same page.
Nothing is going to make visitors leave quicker than annoying them by making them jump around the site.

Liken it to a shop. What would you do if you got to the counter and the assistant informed you "This is is wrong. Could you pop into that closet, read the message, then retrace your steps twice and try again"



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Since I am still having problem implementing your recommendation (great recommendation, by the way; thank you), I decided to create a global.asa file and assign a value to session variable cartItem:

Sub Session_OnStart
'Shopping cart array
Const cartAttributes = 5
Const maxCartItems = 10
ReDim arrcart(cartAttributes,maxCartItems)

Session("MyCart") = arrcart
Session("cartItem") = 1

End Sub

Yet it still isn't working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top