Groups | Blog | Home
all groups > inetserver asp general > july 2006 >

inetserver asp general : ASP Different Results In Firefox And IE !


lovely_angel_for_you NO[at]SPAM yahoo.com
7/30/2006 6:31:02 PM
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
lovely_angel_for_you NO[at]SPAM yahoo.com
7/30/2006 6:35:40 PM
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
lovely_angel_for_you NO[at]SPAM yahoo.com
7/30/2006 7:03:45 PM
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
Slim
7/31/2006 12:00:00 AM
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

[quoted text, click to view]

Bobbo
7/31/2006 7:39:26 AM

[quoted text, click to view]

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.
AddThis Social Bookmark Button