Ask a Question related to Dreamweaver AppDev, Design and Development.
-
USPO #1
Using cfoutput within a cfif statement
I am trying to setup a form validation, what i need to do is look at the
Specimen Number entered and compare it against the database to see if it
already exists. What i am trying now is to place a query and a cfif statement
just before the insert query runs, and using the <cfabort> to stop it if a
match is found.
Here is what i have so far.
<cfquery name="rsSpecNoVerify" datasource="TNMP_DB_be_TRACS">
SELECT SPEC_NO FROM URINE WHERE SPEC_NO = <CFQUERYPARAM
CFSQLTYPE="CF_SQL_VARCHAR" VALUE="#FORM.SpecimenNum#">
</cfquery>
<cfif "<cfoutput>#rsSpecNoVerify.SPEC_NO#</cfoutput>" EQ #FORM.SpecimenNum#>
<h1>ERROR! Duplicate Specimen Number</h1>
<cfabort>
</cfif>
I don't get any errors but it continues to insert the record even though i am
entering a specimen number that i know already exists. I am using the
cfqueryparam statement because while the field is numeric 90% of the time there
are some tests that have a number that starts with "hh" so the field type is
set to string, and without the cfqueryparam i get a data type mismatch.
Should i be going about this a different way ? I believe the problem is with
the cfoutput being inside the cfif statement, but i can't seem to find a way to
fix it, i tried it without the " but i get a syntax error when i do.
I am still new to CF and web development, so i am still working on the Syntax.
Thanks for any help.
USPO Guest
-
Repeating output with cfif statement
I have a problem when multiple checkboxes are "turned on' when multiple values exist for a field in a database. For example: The following code... -
Help with cfif statement
Can anyone help me find the correct way to write the following statement? <cfif form.user2 NEQ 15 or 50 or 51 or 52 or 53 or 55 or 200 or 223 or... -
Cannot put <cfoutput> around a <select> statement usinga query.
<select name="t#this_tourn#_course_id"> <cfoutput query="get_courses"> <option value="#course_id#"> #course_name# - Par #par#</option> </select>... -
CFIF Statement problems
I am trying to write a cfif statement, which shows a form only if the statemnt acts true. It is a 3 part statement, the first two parts appear to... -
Login error with CFIF statement
Hi all: I'm having trouble with a login CFIF routine. The following code works fine when the login is TRUE, but when I try to login with invalid... -
Paul Whitham TMM #2
Re: Using cfoutput within a cfif statement
I wouldn't bother with a test like you are doing because essentially with
your Query you are are only interested if the recordset contains aby values,
so you could achieve it with the following simplier test
<cfif rsSpecNoVerify.Recordcount GT 0>
<h1>ERROR! Duplicate Specimen Number</h1>
<cfabort>
</cfif>
--
Regards
Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
[url]www.valleybiz.net[/url]
Team Macromedia Volunteer for Ultradev/Dreamweaver MX
[url]www.macromedia.com/support/forums/team_macromedia[/url]
"USPO" <webforumsuser@macromedia.com> wrote in message
news:cvlbo4$j1f$1@forums.macromedia.com...statement> I am trying to setup a form validation, what i need to do is look at the
> Specimen Number entered and compare it against the database to see if it
> already exists. What i am trying now is to place a query and a cfif#FORM.SpecimenNum#>> just before the insert query runs, and using the <cfabort> to stop it if a
> match is found.
>
> Here is what i have so far.
>
> <cfquery name="rsSpecNoVerify" datasource="TNMP_DB_be_TRACS">
> SELECT SPEC_NO FROM URINE WHERE SPEC_NO = <CFQUERYPARAM
> CFSQLTYPE="CF_SQL_VARCHAR" VALUE="#FORM.SpecimenNum#">
> </cfquery>
> <cfif "<cfoutput>#rsSpecNoVerify.SPEC_NO#</cfoutput>" EQi am> <h1>ERROR! Duplicate Specimen Number</h1>
> <cfabort>
> </cfif>
>
> I don't get any errors but it continues to insert the record even thoughthere> entering a specimen number that i know already exists. I am using the
> cfqueryparam statement because while the field is numeric 90% of the timeis> are some tests that have a number that starts with "hh" so the field typewith> set to string, and without the cfqueryparam i get a data type mismatch.
>
> Should i be going about this a different way ? I believe the problem isway to> the cfoutput being inside the cfif statement, but i can't seem to find aSyntax.> fix it, i tried it without the " but i get a syntax error when i do.
>
> I am still new to CF and web development, so i am still working on the>
> Thanks for any help.
>
Paul Whitham TMM Guest
-
USPO #3
Re: Using cfoutput within a cfif statement
Paul,
Thanks, i didn't even think about that, makes perfect sense though, i only
care if the query returns any values at all. How does Homer say it "Doh".
Again, thanks much, it worked like a champ.
P.S. Pass along my thanks to the Dev team that created Dreamweaver, i truly
love working with it & the more i learn the more i like it.
USPO Guest



Reply With Quote

