•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 373,375 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,824 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser:
Views: 1198 | Replies: 2 | Solved
![]() |
•
•
Join Date: Feb 2008
Posts: 16
Reputation:
Rep Power: 1
Solved Threads: 0
I need some help with <cfquery>, I want to authenticate an add form so the user doesn't enter the same value twice or more so I used recordcount like this
but it throws an error like Variable COOL is undefined. I am also using anplication.cfm Application.cfm also in my form, is their anything you can see I am doing wrong or do I have to define the query name cool, it is already defined in the cfquery?
ColdFusion Syntax (Toggle Plain Text)
<cfquery name="cool.recordcount" datasource="#Request.proto#"> <cfif cool EQ 0> INSERT INTO proton( name, moon ) VALUES( '#Trim(Form.name)#', '#Trim(Form.moon)#', ) <cfif cool EQ 0> <cfelse> THIS RECORD ALREADY EXIST <cfinclude template="adduser.cfm"> </cfif> </cfquery>
but it throws an error like Variable COOL is undefined. I am also using anplication.cfm Application.cfm also in my form, is their anything you can see I am doing wrong or do I have to define the query name cool, it is already defined in the cfquery?
Last edited by peter_budo : Mar 30th, 2008 at 5:35 am. Reason: Keep It Organized - please use [code] tags
First of all, please don't name your query cool.recordCount. RecordCount is a property of the query object. Name it something like qryCool.
Secondly, you're missing a </cfif> tag. You have two cfif statements, but only one closing.
Do you already have code that determines if this is a duplicate record? What is the 'cool' variable for? If you already check, try this code and let me know:
Change the adduser.cfm to include it's own <cfquery> tag.
Alternately, you can do it all in SQL if you haven't determined whether this is a duplicate record or not.
Secondly, you're missing a </cfif> tag. You have two cfif statements, but only one closing.
Do you already have code that determines if this is a duplicate record? What is the 'cool' variable for? If you already check, try this code and let me know:
ColdFusion Syntax (Toggle Plain Text)
<cfif cool EQ 0> <cfquery name="qryCool" datasource="#Request.proto#"> INSERT INTO proton( name, moon ) VALUES( '#Trim(Form.name)#', '#Trim(Form.moon)#' ) </cfquery> <cfelse> This Record Already Exists <cfinclude template="adduser.cfm"> </cfif>
Change the adduser.cfm to include it's own <cfquery> tag.
Alternately, you can do it all in SQL if you haven't determined whether this is a duplicate record or not.
ColdFusion Syntax (Toggle Plain Text)
<cfquery name="qryCool" datasource="#Request.proto#"> IF NOT EXISTS ( SELECT name, moon FROM proton WHERE name = '#Trim(Form.name)#' AND moon = '#Trim(Form.moon)#' ) BEGIN INSERT INTO proton( name, moon ) VALUES( '#Trim(Form.name)#', '#Trim(Form.moon)#' ) SELECT SCOPE_IDENTITY() AS RecordID END ELSE SELECT NULL AS RecordID </cfquery> <cfif qryCool.RecordID EQ ""> This Record Already Exists <cfelse> <!--- Do something here ---> </cfif>
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ColdFusion Marketplace
Similar Threads
- Undefined Element Error (ColdFusion)
- MS Access Error - sometimes (ColdFusion)
Other Threads in the ColdFusion Forum
- Previous Thread: IMAGE AND TEXT FORM(HELP!!!)
- Next Thread: <cfinput type="checkbox"> Validation


Linear Mode