Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: dynamically named inputs not being passed to database


Message #1 by craigmrobertson@h... on Wed, 26 Sep 2001 11:00:07
i have a list of inputs that are dynamically named from a database. when 

the user submits the answers to these inputs they do not get stored in the 

database. 

in the example below, the variables b and y are not being passed into the 

fields q_id and a.

Please help! thanks.



here is the first bit of code:

strConnection = "driver

{mysql};server=10.0.0.246;uid=root;database=skillsline"

Set adoDataConn = Server.CreateObject("ADODB.Connection") 

adoDataConn.Open strConnection 



if NOT isempty(Request.Form("Insert")) then

adoDataConn.Execute "insert into tna_results (user_id, category_id, q_id, 

a) " _

	& "values (" _

	& "'" & Request.Form("user_id") & "', " _

	& "'" & Request.Form("category_id") & "', " _

	& "'" & b & "', " _

	& "'" & y & "')"

	response.redirect "./tna_categories.asp"

end if



SQLStmt = "select * from tna_questions where category_id = "_

	& request.querystring("category_id")



set q = Server.CreateObject("ADODB.Recordset")

q.ActiveConnection = strConnection

q.Open SQLStmt, , , 4, 1

	      

%>



AND HERE IS THE FORM STUFF



<FORM action="tna_questions.asp"  METHOD=POST>

<% do until q.eof %>

	<p>

	<%dim x

	dim y

	dim a

	dim b

	x = "a"

	y = x & q("q_id")

	a = "q_id"

	b = a & q("q_id")

	%>

<input type="hidden" name="user_id" value=<% response.write session

("user_id") %>>

<input type="hidden" name="category_id" value=<% response.write q

("category_id") %>>

	<input type="hidden" name="<%response.write b%>" value="<%

response.write q("q_id")%>">

	  <% response.write q("q_text") %><p>

	  1 <input type="radio" name="<% response.write y %

>" value=1>

	  2 <input type="radio" name="<% response.write y %

>" value=2>

	  3 <input type="radio" name="<% response.write y %

>" value=3>

	  4 <input type="radio" name="<% response.write y %

>" value=4>

	  5 <input type="radio" name="<% response.write y %

>" value=5>

<p>

<% q.movenext 

loop 

q.close

set q=nothing%>

Message #2 by Kyle Burns <kburns@c...> on Wed, 26 Sep 2001 08:03:03 -0500
It doesn't look like you've assigned values to the variables b and y at the

time that you run your statement.  My first suggestion would be to place

your SQL statement into a variable (e.g. sSQL) and then do a Response.Write

of the variable that you have assigned the SQL statement.





=================================

Kyle M. Burns, MCSD

ECommerce Technology Manager

Centra Credit Union

kburns@c...



 



-----Original Message-----

From: craigmrobertson@h... [mailto:craigmrobertson@h...]

Sent: Wednesday, September 26, 2001 6:00 AM

To: ASP Databases

Subject: [asp_databases] dynamically named inputs not being passed to

database





i have a list of inputs that are dynamically named from a database. when 

the user submits the answers to these inputs they do not get stored in the 

database. 

in the example below, the variables b and y are not being passed into the 

fields q_id and a.

Please help! thanks.



here is the first bit of code:

strConnection = "driver

{mysql};server=10.0.0.246;uid=root;database=skillsline"

Set adoDataConn = Server.CreateObject("ADODB.Connection") 

adoDataConn.Open strConnection 



if NOT isempty(Request.Form("Insert")) then

adoDataConn.Execute "insert into tna_results (user_id, category_id, q_id, 

a) " _

	& "values (" _

	& "'" & Request.Form("user_id") & "', " _

	& "'" & Request.Form("category_id") & "', " _

	& "'" & b & "', " _

	& "'" & y & "')"

	response.redirect "./tna_categories.asp"

end if



SQLStmt = "select * from tna_questions where category_id = "_

	& request.querystring("category_id")



set q = Server.CreateObject("ADODB.Recordset")

q.ActiveConnection = strConnection

q.Open SQLStmt, , , 4, 1

	      

%>



AND HERE IS THE FORM STUFF



<FORM action="tna_questions.asp"  METHOD=POST>

<% do until q.eof %>

	<p>

	<%dim x

	dim y

	dim a

	dim b

	x = "a"

	y = x & q("q_id")

	a = "q_id"

	b = a & q("q_id")

	%>

<input type="hidden" name="user_id" value=<% response.write session

("user_id") %>>

<input type="hidden" name="category_id" value=<% response.write q

("category_id") %>>

	<input type="hidden" name="<%response.write b%>" value="<%

response.write q("q_id")%>">

	  <% response.write q("q_text") %><p>

	  1 <input type="radio" name="<% response.write y %

>" value=1>

	  2 <input type="radio" name="<% response.write y %

>" value=2>

	  3 <input type="radio" name="<% response.write y %

>" value=3>

	  4 <input type="radio" name="<% response.write y %

>" value=4>

	  5 <input type="radio" name="<% response.write y %

>" value=5>

<p>

<% q.movenext 

loop 

q.close

set q=nothing%>



 




$subst('Email.Unsub')


  Return to Index