2 Replies - 3627 Views - Last Post: 26 April 2007 - 10:30 AM Rate Topic: -----

#1 big_popa   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-April 07

form data in a database

Post icon  Posted 21 April 2007 - 08:48 AM

i'm currently learning to use coldfusion so i'll appologize in advance if my question of a basic nature.

i have a form to capture user information and will pass the data to a processing page where i want to have it entered into a table.

i've tested the form with a debugging page and the data passes to the test page without a problem. when the processing query is accessed, i receive an error that the element ADDRESS is undefined in the form.

processing query:
 <cfquery datasource="YardSale" name="enterYardSale">
Insert into YardSale (requestid,name,address,city,state,zipcode,phone,email,booth,comments)
Values (request_seq.nextval, #form.Name#, #form.address#, #form.city#, #form.state#, #form.zipcode#, #form.Phone#, #form.Email#, #form.booth#, #form.comments#,)
</cfquery> 


since the data passes to the test page, i'm thinking there is something wrong with my processing query.

also, for the table i created a number sequence for the key field to track the number of submissions. do i need to include this in the processing query as i have above? or if this is omitted, will the table populate the number as the other fields are entered?

Is This A Good Question/Topic? 0
  • +

Replies To: form data in a database

#2 tundrafiend01   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-April 07

Re: form data in a database

Posted 23 April 2007 - 10:45 AM

View Postbig_popa, on 21 Apr, 2007 - 08:48 AM, said:

i'm currently learning to use coldfusion so i'll appologize in advance if my question of a basic nature.

i have a form to capture user information and will pass the data to a processing page where i want to have it entered into a table.

i've tested the form with a debugging page and the data passes to the test page without a problem. when the processing query is accessed, i receive an error that the element ADDRESS is undefined in the form.

processing query:
 <cfquery datasource="YardSale" name="enterYardSale">
Insert into YardSale (requestid,name,address,city,state,zipcode,phone,email,booth,comments)
Values (request_seq.nextval, #form.Name#, #form.address#, #form.city#, #form.state#, #form.zipcode#, #form.Phone#, #form.Email#, #form.booth#, #form.comments#,)
</cfquery> 


since the data passes to the test page, i'm thinking there is something wrong with my processing query.

also, for the table i created a number sequence for the key field to track the number of submissions. do i need to include this in the processing query as i have above? or if this is omitted, will the table populate the number as the other fields are entered?


Greetings:

The only issue I found in your code is the extra comma after #form.comments#. Instead of:

 <cfquery datasource="YardSale" name="enterYardSale">
Insert into YardSale (requestid,name,address,city,state,zipcode,phone,email,booth,comments)
Values (request_seq.nextval, #form.Name#, #form.address#, #form.city#, #form.state#, #form.zipcode#, #form.Phone#, #form.Email#, #form.booth#, #form.comments#,)
</cfquery> 


Try:

 <cfquery datasource="YardSale" name="enterYardSale">
Insert into YardSale (requestid,name,address,city,state,zipcode,phone,email,booth,comments)
Values (request_seq.nextval, #form.Name#, #form.address#, #form.city#, #form.state#, #form.zipcode#, #form.Phone#, #form.Email#, #form.booth#, #form.comments#)
</cfquery> 


That may not fix the error message you are receiving, but it will help you once you get your current issue resolved. You also might try posting the code for your input page and your processing pages. Finally, I would suggest using uniform variable naming procedure for code readability and maintainability.
Was This Post Helpful? 0
  • +
  • -

#3 ajwsurfer   User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 376
  • Joined: 24-October 06

Re: form data in a database

Posted 26 April 2007 - 10:30 AM

There are a few things that could be wrong here
* There are no single quotes around the
#form.address#
value.
Maybe try something like
'#form.address#'
That might not be the only field with this problem in the query.

* If the field type is number (integer, real, etc...) and it is a null value, Coldfusion mistakenly writes the syntax like this ,, rather than ,NULL, so you need to place a qualifying switch in there to solve the problem, like so:
<cfif Len(getReaches.STRAI_LEN) EQ 0>Null<cfelse>#getReaches.STRAI_LEN#</cfif>,


* And finaly the field might not exist.
You could try wrapping the statement with <cfoutput> statements to see what the actual code looks like at runtime, like this:
	
<cfoutput>
Insert into YardSale (requestid,name,address,city,state,zipcode,phone,email,booth,comments)
Values (request_seq.nextval, #form.Name#, #form.address#, #form.city#, #form.state#, #form.zipcode#, #form.Phone#, #form.Email#, #form.booth#, #form.comments#,)
</cfoutput>


Now you can run the page (place something in there to stop it so you can see it, like just comment out the rest of the page using <!--- rest of page --->). Next copy and paste that actual statement into the DBMS (Database Management System) and see if it works.

This should nail down the problem. :)

This post has been edited by ajwsurfer: 26 April 2007 - 10:34 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1