rabbits2
asked on
INSERT statement - values of check boxes data type problem
Hi, I have this INSERT statement below and am not sure how to correct it to insert a checked or unchecked value of a check box. The check box is name txtage.
session ("strage")=Request.Form ("txtage")
function checkform
If session ("strage")="no" then
response.redirect "caukus.asp?type=18&msg="& server.url encode("Pl ease confirm you are 18 or over")
exit function
End If
End Function
call checkform
SQLINSERT = "INSERT INTO tbl_application(firstname, surname,us ername,pas sword,mobi le,driving _licence,d ob,confirm _age,email ) values('" & replace(session ("strfirstname"), "'", "")& "','" & replace(session ("strsurrname "), "'", "")& "','" & replace(session ("strusername"), "'", "")& "','" & replace(session ("strpassword"), "'", "")& "','" & replace(session ("strmob"), "'", "")& "','" & replace(session ("strdrivinglicence"), "'", "")& "','" & replace(session ("strdob"), "'", "")& "','" & replace(session ("strage"), "'", "")& "','" & replace(session ("stremail"), "'", "")& "')"
objConn.execute(SQLINSERT)
Thanks for the help.
session ("strage")=Request.Form ("txtage")
function checkform
If session ("strage")="no" then
response.redirect "caukus.asp?type=18&msg="&
exit function
End If
End Function
call checkform
SQLINSERT = "INSERT INTO tbl_application(firstname,
objConn.execute(SQLINSERT)
Thanks for the help.
ASKER
No that bit works, sorry it is the INSERT statement that doesn't work this bit:
'" & replace(session ("strage"), "'", "")& "'
The error I am getting is 'mis match data type'.
Thanks
'" & replace(session ("strage"), "'", "")& "'
The error I am getting is 'mis match data type'.
Thanks
If session ("strage")="" then
response.write("please select age")
Else
myChk = 1 ' if access database myChk = true
End if
how do you define the database checkbox field ?
string? yes/no filed?
you should define myChk according to your field
or
you can enter the checkbox value on your form field value="true" or value="1"
then you can directly inster your session("strage")
response.write("please select age")
Else
myChk = 1 ' if access database myChk = true
End if
how do you define the database checkbox field ?
string? yes/no filed?
you should define myChk according to your field
or
you can enter the checkbox value on your form field value="true" or value="1"
then you can directly inster your session("strage")
ASKER
In my Db I define the checkbox field yes/no
so how do I define myChk in my form which at the moment looks like this:
<td colspan="3" valign="top" class="text_2" style="height:21 "><input type="checkbox" name="txtage" value="checkbox"> <%displayMessage(17)%> </td>
so how do I define myChk in my form which at the moment looks like this:
<td colspan="3" valign="top" class="text_2" style="height:21 "><input type="checkbox" name="txtage" value="checkbox"> <%displayMessage(17)%> </td>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Still mis match data type error. Could you explain why you have taken off the replace () around session("strage")
made all the changes you suggested.
made all the changes you suggested.
ASKER
And the reason it is only surrounded by "" rather than '""'
Just checking my code for this section:
if session ("strage")<>"true" then
response.redirect "caukus.asp?type=18&msg="& server.url encode("Pl ease confirm you are 18 or over")
exit function
elseif session ("strage")="false" then
exit function
elseif session ("stremployment")="" then
response.redirect "caukus.asp?type=19&msg="& server.url encode("Pl ease enter your current employment")
exit function
end if
end fucntion
Just checking my code for this section:
if session ("strage")<>"true" then
response.redirect "caukus.asp?type=18&msg="&
exit function
elseif session ("strage")="false" then
exit function
elseif session ("stremployment")="" then
response.redirect "caukus.asp?type=19&msg="&
exit function
end if
end fucntion
do
response.write(session("st rage"))
response.end
then tell us what the results are. if it's nothing then that's your problem. it's not passing the value.
i suggest doing something like this, on the page put
strAge = false
if session("strAge")="true" then
strAge = true
end if
'then your insert
SQLINSERT = "INSERT INTO tbl_application(firstname, surname,us ername,pas sword,mobi le,driving _licence,d ob,confirm _age,email ) values('" & replace(session ("strfirstname"), "'", "")& "','" & replace(session ("strsurrname "), "'", "")& "','" & replace(session ("strusername"), "'", "")& "','" & replace(session ("strpassword"), "'", "")& "','" & replace(session ("strmob"), "'", "")& "','" & replace(session ("strdrivinglicence"), "'", "")& "','" & replace(session ("strdob"), "'", "")& "'," & strAge & ",'" & replace(session ("stremail"), "'", "")& "')"
objConn.execute(SQLINSERT)
you should be using yes/no field in your database. if this doesn't work, it might be one of your other fields that's causing the issue.
response.write(session("st
response.end
then tell us what the results are. if it's nothing then that's your problem. it's not passing the value.
i suggest doing something like this, on the page put
strAge = false
if session("strAge")="true" then
strAge = true
end if
'then your insert
SQLINSERT = "INSERT INTO tbl_application(firstname,
objConn.execute(SQLINSERT)
you should be using yes/no field in your database. if this doesn't work, it might be one of your other fields that's causing the issue.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In the unlikely case that it is not, post the results of the following line:
Response.Write SQLINSERT
Response.Write SQLINSERT
ASKER
i am getting the error below:
Syntax error in INSERT INTO statement.
When I
Response.Write SQLINSERT
Response.End
I get this:
INSERT INTO tbl_application(firstname, surname,us ername,pas sword,mobi le,confirm _age,email ) values('Firstname','Surnam e','user89 888','pass 98998','07 8998878876 ',,'','ema il@hot.com ')
My insert statement is as follows:
SQLINSERT = "INSERT INTO tbl_application(firstname, surname,us ername,pas sword,mobi le,confirm _age,email ) values('" & replace(session ("strfirstname"), "'", "")& "','" & replace(session ("strsurname"), "'", "")& "','" & replace(session ("strusername"), "'", "")& "','" & replace(session ("strpassword"), "'", "")& "','" & replace(session ("strmob"), "'", "")& "'," & strAge & ",'"& "','" & replace(session ("stremail"), "'", "")& "')"
Thanks fo ryour help.
Syntax error in INSERT INTO statement.
When I
Response.Write SQLINSERT
Response.End
I get this:
INSERT INTO tbl_application(firstname,
My insert statement is as follows:
SQLINSERT = "INSERT INTO tbl_application(firstname,
Thanks fo ryour help.
you have an error in your sql statement
SQLINSERT = "INSERT INTO tbl_application(firstname, surname,us ername,pas sword,mobi le,confirm _age,email ) values('" & replace(session ("strfirstname"), "'", "")& "','" & replace(session ("strsurname"), "'", "")& "','" & replace(session ("strusername"), "'", "")& "','" & replace(session ("strpassword"), "'", "")& "','" & replace(session ("strmob"), "'", "")& "'," & strAge & ",'"& "','" & replace(session ("stremail"), "'", "")& "')"
-----------------^ this part!
when you get this
INSERT INTO tbl_application(firstname, surname,us ername,pas sword,mobi le,confirm _age,email ) values('Firstname','Surnam e','user89 888','pass 98998','07 8998878876 ',,'','ema il@hot.com ')
you are trying to insert 8 values in 7 fields
change your SQL statement to this
SQLINSERT = "INSERT INTO tbl_application(firstname, surname,us ername,pas sword,mobi le,confirm _age,email ) values('" & replace(session ("strfirstname"), "'", "")& "','" & replace(session ("strsurname"), "'", "")& "','" & replace(session ("strusername"), "'", "")& "','" & replace(session ("strpassword"), "'", "")& "','" & replace(session ("strmob"), "'", "")& "'," & strAge & ",'" & replace(session ("stremail"), "'", "")& "')"
SQLINSERT = "INSERT INTO tbl_application(firstname,
-----------------^ this part!
when you get this
INSERT INTO tbl_application(firstname,
you are trying to insert 8 values in 7 fields
change your SQL statement to this
SQLINSERT = "INSERT INTO tbl_application(firstname,
sorry, the bad part in SQL statement it's this
" & strAge & ",'"& "','" & replace(session ("stremail"), "'", "")& "')"
-------------------^
after strAge and before strEmail, you have '"& "',
" & strAge & ",'"& "','" & replace(session ("stremail"), "'", "")& "')"
-------------------^
after strAge and before strEmail, you have '"& "',
ASKER
Changed it to:
SQLINSERT = "INSERT INTO tbl_application(firstname, surname,us ername,pas sword,mobi le,confirm _age,email ) values('" & replace(session ("strfirstname"), "'", "")& "','" & replace(session ("strsurname"), "'", "")& "','" & replace(session ("strusername"), "'", "")& "','" & replace(session ("strpassword"), "'", "")& "','" & replace(session ("strmob"), "'", "")& "'," & strAge & ",'" & replace(session ("stremail"), "'", "")& "')"
and still getting syntax error, any ideas?
SQLINSERT = "INSERT INTO tbl_application(firstname,
and still getting syntax error, any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
response.write("please select age")
End if