Conditional If Statement- Syntax Isse - Coldfusion

I have a cfif statement that is not functioning as I believed it was.  
astatus = blank
duserid = 12
session.uid = 12
qChkAuth.recordcount = 0
session.auth.userrole = 4

Minus qChkAuth.recordcount not being '1', all other conditons in the and (( "OR")) statement are satisfied. So I should fall into the first section of conditional if. But I am defaulting to the <cfesle>

What is wrong with my conditional statement?

<cfif (astatus is "") and ((#duserid# is #session.uid#) or (#qChkAuth.recordcount# is 1) or (#SESSION.Auth.Userrole# is 4))>

	<td  align="left"  valign="top"><a href="update2.cfm?rec_id=#drec_id#&control=#control_id#&location=#origin#"> 
	<strong><font face="Arial" color="blue" size="-1">#drec_id#</td>
	</font>
	Made it to admin level
<cfelse>
	<td  align="left" size="-1" valign="top"><a href="display1.cfm?rec_id=#drec_id#&location=#origin#"> 
	<strong><font face="Arial" color="blue" size="-1">#drec_id#</td>
	</font>
	not admin
</cfif>

Open in new window

mahpogAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_agx_Commented:
Maybe the values aren't what you think they are? Because it does produce the expected results using the values you supplied

<cfset astatus = "">
<cfset duserid = 12>
<cfset session.uid = 12>
<cfset qChkAuth.recordcount = 0>
<cfset session.auth.userrole = 4>

<cfif (astatus is "") and ((#duserid# is #session.uid#) or (#qChkAuth.recordcount# is 1) or (#SESSION.Auth.Userrole# is 4))>
	Made it to admin level
<cfelse>
	not admin
</cfif>

Open in new window


Print out the results of each comparison to see what's not matching the expected result

<cfoutput>
astatus[#astatus#] is "" = #(astatus is "")#<br> 
duserid[#duserid#] is session.uid[#session.uid #] = #(duserid is session.uid)#<br> or 
qChkAuth.recordcount[#qChkAuth.recordcount#] is 1 = #(qChkAuth.recordcount is 1)#<br> 
SESSION.Auth.Userrole [#SESSION.Auth.Userrole#] is 4 = #(SESSION.Auth.Userrole is 4)#<br>
</cfoutput>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gdemariaCommented:
no points..

 chances are it's your astatus field, perhaps it contains a space instead of empty?

 <cfif len(trim(astatus)) eq 0 and (.....)>

 
0
Gurpreet Singh RandhawaCEOCommented:
Hi!

Here is my Try

try This

<cfset isStatus = IsDefined("astatus") AND astatus EQ "">
<cfset isUserID = isDefined("duserid") AND duserid EQ 12>
<cfset isID = IsDefined("session.uid") AND session.uid EQ 12>
<cfset isRole = IsDefined("session.auth.userrole") AND session.auth.userrole EQ 4>
<cfset isCheck = isDefined("qChkAuth.recordcount") AND qChkAuth.recordcount EQ 0>

<cfif (isStatus AND (isUserID EQ isID)) OR (isCheck) OR isRole>
        Made it to admin level
<cfelse>
        not admin
</cfif>

Try Dumping each value and use it, it will work!

Cheers
0
mahpogAuthor Commented:
thank you all!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.