Okay, at the top of the template i have this:
<cfset dbfields="firstname,lastname,phone,fax,email,address1,address2,city,state,zip">
Then I have this query which:
<cfquery name="checkbdup" datasource="mydata" maxrows="1">
SELECT max(bID) from billing
WHERE 0=0
<cfloop list="#dbfields#" index="i">
<cfif len(evaluate(i))>
and #i# = '#evaluate(i)#'
</cfif>
</cfloop>
</cfquery>
Now, if no results from the query come back I want to do one thing, otherwise something else - here is the code:
<cfif checkbdup.recordcount gt 0>
<cfset billingID = #checkbdup.bID#>
<cfelse>
<!--- if not in database, we insert the info, then get their ID's for future ref --->
<cfinsert datasource="#application.ds#" formfields="#dbfields#" tablename="billing">
As i test this template there is no info in the billing table and there is a column called bID (i have double checked this). So, the cfif test for checkbdup.recordcount gt o should be false and therefore the else code should kick in BUT when i run this i get the following error:
Error resolving parameter CHECKBDUP.BID
The column BID is not present in the query named CHECKBDUP. It is likely that you have misspelled the name of the column.
The error occurred while evaluating the expression:
billingID = #checkbdup.bID#
The error occurred while processing an element with a general identifier of (CFSET), occupying document position (36:6) to (36:40).
First of all, that column is in the query, second, cf shouldnt be trying to evaluate that expression since the recordcount should not be greater than zero (again, there is nothing in that table yet). Anyone see the problem here?
<cfset dbfields="firstname,lastname,phone,fax,email,address1,address2,city,state,zip">
Then I have this query which:
<cfquery name="checkbdup" datasource="mydata" maxrows="1">
SELECT max(bID) from billing
WHERE 0=0
<cfloop list="#dbfields#" index="i">
<cfif len(evaluate(i))>
and #i# = '#evaluate(i)#'
</cfif>
</cfloop>
</cfquery>
Now, if no results from the query come back I want to do one thing, otherwise something else - here is the code:
<cfif checkbdup.recordcount gt 0>
<cfset billingID = #checkbdup.bID#>
<cfelse>
<!--- if not in database, we insert the info, then get their ID's for future ref --->
<cfinsert datasource="#application.ds#" formfields="#dbfields#" tablename="billing">
As i test this template there is no info in the billing table and there is a column called bID (i have double checked this). So, the cfif test for checkbdup.recordcount gt o should be false and therefore the else code should kick in BUT when i run this i get the following error:
Error resolving parameter CHECKBDUP.BID
The column BID is not present in the query named CHECKBDUP. It is likely that you have misspelled the name of the column.
The error occurred while evaluating the expression:
billingID = #checkbdup.bID#
The error occurred while processing an element with a general identifier of (CFSET), occupying document position (36:6) to (36:40).
First of all, that column is in the query, second, cf shouldnt be trying to evaluate that expression since the recordcount should not be greater than zero (again, there is nothing in that table yet). Anyone see the problem here?