Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

coldfusion string comparison

I have a form that returns a list like this when submitted:

2009,9

I want to compare it to database pulled values but keep getting an error.

<cfif #FORM.month# eq #qGetDates.year#,#qGetDates.month#>

I know I probably have to cast it or convert it to a string for the comparison to work, how do I do this?

Thanks,

R.

like image 892
Roscoeh Avatar asked Dec 05 '22 01:12

Roscoeh


2 Answers

<cfif FORM.month eq "#qGetDates.year#,#qGetDates.month#">

or

<cfif compare(FORM.month, "#qGetDates.year#,#qGetDates.month#") EQ 0>
like image 80
Henry Avatar answered Jan 06 '23 00:01

Henry


You are overusing #. Unless variables are inside quotation marks or a cfoutput block, you don't use # as a general rule.

Another rule: You must use quotes around strings (the comma in this case). You can also include variables in your strings with the rule above (use #) as seen in Henry's example.

<cfif #FORM.month# eq #qGetDates.year#,#qGetDates.month#>

should have # removed and the comma needs the string concatenated

<cfif FORM.month eq qGetDates.year & "," & qGetDates.month>

Or as Henry said

like image 45
J.T. Avatar answered Jan 05 '23 23:01

J.T.