Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
tharring #1
Using selection list in search query
Is there something new in CFMX 6.1 that causes the following statement to not
work correctly? I get an error when trying to load the page. I'd really like to
be able to use a selection list for multiple committee names in my search
query. Thanks. <cfquery name='etc' datasourceu='etc'> SELECT * FROM contacts
WHERE committees in (#PreserveSingleQuotes(form.selectcom)#) </cfquery> Error
Occurred While Processing Request The system has attempted to use an
undefined value, which usually indicates a programming error, either in your
code or some system code. Null Pointers are another name for undefined values.
The error occurred in D:\e-caa.com\wwwroot\user\groupem\2selectcom.cfm:
line 5 3 : 4 : <cfquery name='rsChEmail' datasource=#MM_Concaa_DSN#
username=#MM_Concaa_USERNAME# password=#MM_Concaa_PASSWORD#> 5 : SELECT * FROM
contacts WHERE committees in (#PreserveSingleQuotes(form.selectcom)#) 6 :
</cfquery>
tharring Guest
-
drop down list selection
Hi all There's probably a simple answer to this - but I don't know it! I have a drop-down list, populated from a database. When a user enters... -
List box not retaining selection
I have a drop-down list box, populated from a database table. It works fine, but after making a selection from the drop-down list the boxn goes... -
PHP selection list
Can anyone tell how to get the selection value stored in the variable and use that selection to produce another selection list .... hope you... -
List box selection
I have a list of objects in a list box that I need to select all at once. Is there a way to do this? -
Selection of records in list
Dear folks: I was wondering how to query MySQL to display only a selection (1-20, 21-40) of a query in an HTML list. Can that be done in an SQL... -
toniu27 #2
Re: Using selection list in search query
form.selectcom is the "undefined value"
Do you check the existance of form.selectcom before using it?
I dont think it caused by function PreserveSingleQuotes.
toniu27 Guest
-
zoeski80 #3
Re: Using selection list in search query
Before you use the variable you can just check if it exists to make sure that
there was something selected by the user on the form.
You should always check if a variable exists if it is coming from a checkbox
or radio box on the form as if nothing is selected by the user the parameter
will not be passed through from the form at all.
Even if you've used a SELECT box the user could have selected something with
no value in which case the variable will be empty. Doing a query on WHERE
Committees in () will produce an error too so you could put a CFIF
Trim(Variable) NEQ '' around the list comparison within the query too.
HTH
<cfquery name="rsChEmail" datasource=#MM_Concaa_DSN#
username=#MM_Concaa_USERNAME# password=#MM_Concaa_PASSWORD#>
SELECT *
FROM contacts
<CFIF IsDefined("form.selectcom") AND Trim(form.selectcom) NEQ ''>
WHERE committees in (#PreserveSingleQuotes(form.selectcom)#)
<CFELSE>
WHERE 0=1
</CFIF>
</cfquery>
zoeski80 Guest



Reply With Quote

