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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert Request.Cookies("value") into database

Status
Not open for further replies.

alwayson

Technical User
Mar 3, 2002
6
US
I was wondering if anyone had a minute to check out the following code and tell me what I am doing wrong:

----------------------------------------------------------
<%
f_name = Request.Cookies(&quot;First_Name&quot;)
l_name = Request.Cookies(&quot;Last_Name&quot;)
ss = Request.Cookies(&quot;SSN&quot;)
eml = Request.Cookies(&quot;email&quot;)
comp = Request.Cookies(&quot;CO&quot;)
loc = Request.Cookies(&quot;loc&quot;)
tot = Request.Cookies(&quot;total&quot;)

cst = &quot;Driver={Microsoft Access Driver (*.mdb)};DBQ=&quot;
cst = cst & server.mappath(&quot;../../db/fpdb/boyderstestresults.mdb&quot;)
set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.open cst

sql = &quot;INSERT INTO results(fname) VALUES(f_name)&quot;
conn.execute(sql)
conn.close
cst = 0
%>
-----------------------------------------------------
The code works if I put quotes around f_name, 'f_name'
but then it enters the word f_name into my table, not the value of f_name retrieved from the cookie value.

Sincere thanks
 
Your code:
...
sql = &quot;INSERT INTO results(fname) VALUES(f_name)&quot;

should be:

sql = &quot;INSERT INTO results(fname) VALUES('&quot; & f_name & &quot;')&quot;

///edox
..
 
One last thing,

what if I wanted to enter the values of all the cookies into my table?

thanks
 
Hi There ...
it's very simple.
sql = &quot;INSERT INTO results(fname,lname,email)
VALUES('&quot; & f_name & &quot;', '&quot; & l_name & &quot;', '&quot;& eml &&quot;')
and so on ...
TNX
E.T.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top