I am getting error when using evaluate() in coldfusion 2021.
Please see the screenshot
Can I know what's the reason behind it or is there any solution to solve this? In my project I have used this function in many place. Please help me on this.
Copyright © 2021 Jogjafile Inc.
That's trycf.com, right? They've disabled
evaluate. The message even says this.On a well-locked-down server, things like
evaluateare often disabled as they are a penetration vector unless handled properly.As trycf.com is - by design - for running any arbitrary CFML, the server needs to be well locked down. And it is.
However I doubt your concern is really about trycf.com. I presume it's for some other server you use? It'll be for the same reason: security.
There's almost never a reason to use
evaluate, and using it is considered poor practice in a lot of circles. Given you can't use it in your case, I'd refactor the code to not need it.In your specific example (also please in future don't post pictures of code and/or error messages: post the text!) you don't need
evaluate. You just need this:evaluateis for evaluating one or more strings that contain code expressions. It's absolutely pointless here. One should always have read the docs for any programming construct one is using. Especially if one is having problems with it.