PDA

View Full Version : trouble with insert into db with jscript


bigdude
09-23-2002, 06:59 AM
hello
using mysql server with asp and jscript
it looks like the jscript doesn't like "" around variables in the insert string....
can anyone help me on how to get the value of a variable into this?
here are some things i've tried:

var insertBird=Request.Form("txtBird");
result=conn.Execute("INSERT INTO birds VALUES('$insertBird$')");
// database gets "$insertBird$"
result=conn.Execute("INSERT INTO birds VALUES('$insertBird')");
// database gets "$insertBird"
result=conn.Execute("INSERT INTO birds VALUES('insertBird')");
// database error that there is no col "insertbird"
result=conn.Execute("INSERT INTO birds VALUES('"insertBird"')");
// jscript error that it expects ";" after "('"

anyone help on this?
thanks in advance

glenngv
09-23-2002, 07:46 AM
haven't used jscript on server-side.
this is just an educated guess:

result=conn.Execute("INSERT INTO birds (FIELDNAME_HERE) VALUES('"+insertBird+"')");

bigdude
09-23-2002, 09:08 PM
hi
thanks so much!
it works :)