-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> Hi There,
>
> I'm trying to find why this if condition keeps getting
> evaluated as true
> when it shouldn't. I've traced through the debugger to track
> the value of
> the if condition and even though the record count condition
> comes up as 0
> when I put a watch on it, it still executes.
> I added a CFOUTPUT between the query and the <CFSCRIPT> and it
> always returns a 0 on the page too.
>
> <!--- Check if we're monitoring NT --->
> <cfquery name="Check_NT" datasource="#dsn#" dbtype="#driver_type#">
> select distinct system_type from uv_system_all
> where system_type='NT'
> </cfquery>
>
> <cfoutput>#Check_NT.RecordCount#</cfoutput>
>
> <!--- If we count one or more we add it to an array of structures
> ---> <CFSCRIPT>
> if (Check_NT.RecordCount gt 0 is "TRUE")
> More Code deleted...
The if stament is trying to compare the boolean value from GT
comparison with the string "TRUE".
(Check_NT.RecordCount gt 0) will always equal either 0 or 1.
"TRUE" will always equal "TRUE".
"TRUE" will never be equal to either 1 or 0.
Your if should look like this instead:
if (Check_NT.RecordCount gt 0)
or even:
if (Check_NT.RecordCount)
since in CF a 0 means false and anything that isn't 0 is true.
Hope that helps.
Best regards,
Zac Bedell
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com>
Comment: Please use PGP!
iQA/AwUBOmxzhqvhLS1aWPxeEQJzIgCg8OPwrH3yPKJM3W4aPsdARIaThygAnAnU
4dNmN1JBMygUuRaCKjxVz3ma
=GMZs
-----END PGP SIGNATURE-----
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists