ASP Different Results In Firefox And IE !

  • Thread starter lovely_angel_for_you
  • Start date
L

lovely_angel_for_you

Hi,

I have following code, picking an ID and saving it to Cookies.

<%
ItemID = Request("prod")
Response.Cookies("THREES")(ItemID) = Request("prod")
Set rdset=objConn.Execute("SELECT ID, Name, Large, Description
FROM shop_products WHERE ID=" & ItemID)
%>

In IE it works fine as it should, adding item id to Cookies

In Firefox it gives me the following error:
Cookies object, ASP 0102 (0x80004005)
The function expects a string as input.
/shop/addcart.asp, line 27

Any information on that. Any idea what is going wrong.

Best Wishes
Lovely
 
L

lovely_angel_for_you

As I was using form to send "prod" to next page, using hidden element
in form on previous page.

I update the code as :

<%
ItemID = Request.form("prod")
Response.Cookies("THREES")(ItemID) = Request.form("prod")
Set rdset=objConn.Execute("SELECT ID, Name, Large, Description
FROM shop_products WHERE ID=" & ItemID)
%>

It work in IE, stil doesnt work in FireFox.

Any ideas.

Best Wishes
Lovely
 
L

lovely_angel_for_you

Changed it to:

<%
ItemID = Cstr(Request.form("prod"))
Response.Cookies("THREES")(ItemID) = Request.form("prod")
Set rdset=objConn.Execute("SELECT ID, Name, Large, Description
FROM shop_products WHERE ID=" & Request.form("prod"))
%>

Still in IE its working as it should be, in FireFox, it is not giving
error:

Cookies object, ASP 0183 (0x80004005)
A cookie with an empty key cannot be stored.
/shop/addcart.asp, line 2

Any ideas.

Best Wishes
Lovely
 
S

Slim

You seem to be storing the cookie with the same value for the cookies key as
well as its value as ItemID = Cstr(Request.form("prod"))

is this what you wanted to do?

either way,

response.write ItemID

to see if in fact it does hold a string key
 
B

Bobbo

Slim said:
You seem to be storing the cookie with the same value for the cookies key as
well as its value as ItemID = Cstr(Request.form("prod"))

is this what you wanted to do?

either way,

response.write ItemID

to see if in fact it does hold a string key

Ah, good old ASP and its variant data types.

I've just been playing around and I can reproduce the error thus:
Works : Response.Cookies("monkey")("1") = "badger"
Fails: Response.Cookies("monkey")(1) = "badger"

In which case it's because -- as the error implies -- your parameter
ItemID needs to be explicitly cast as a string, like this:

Response.Cookies("THREES")(CStr(ItemID)) = Request("prod")

CStr forces the variable to have an internal variable type of 'String',
which you can test using the TypeName() function.

http://www.w3schools.com/vbscript/func_typename.asp

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,771
Messages
2,569,587
Members
45,099
Latest member
AmbrosePri
Top