Link to home
Start Free TrialLog in
Avatar of Coast Line
Coast LineFlag for Canada

asked on

Error with Evaluate Function

I have the following legacy code which is causing a stange issues just recently, we upgraded to coldfusion 9

<cfquery name="qCheck" datasource="#ds#">
	select * from authentication
	where id = #val(url.ID)#>
</cfquery>

so the above query does return a row and it has stored value in one of its field which is following as: 

columnName - vchevalemailaddress
Value as - session.email

<cfset a = Evaluate(qCheck.vchevalemailaddress)
<cfoutput>#a#</cfoutput>

Open in new window


Now i am getting an error as:

Element EMAIL is undefined in SESSION.
Avatar of gdemaria
gdemaria
Flag of United States of America image

That is really weird.   The value of the variable is another variable?

Does that make sense for the way it is implemented or perhaps that is the error itself?  Are they intentionally storing a variable in the database?

What is the error?   Perhaps the session.email variable does not exist.
Maybe you have to make sure it exists before getting its value:

<cfif isDefined("#qCheck.vchevalemailaddress#")> <!--- the # are there intentionally
    <cfset a = Evaluate(qCheck.vchevalemailaddress)
    <cfoutput>#a#</cfoutput>
</cfif>
Avatar of Coast Line

ASKER

They are intentionally storing the values in the database,

I am also lost why it is behaving this way, even i ran this piece of code in separate new project where only this table associated and file which have this code shows but it throws error, if you want i can share the code with you here in as zip file
What is the error message?   It seems that some variable pulled from the database may not exist, therefore, you can not get the value.

My code above tries to test to see if the variable exists.   That would be my first guess, the variable that is being output does not exist.
That is my guess too. but al variables have been defined, not sure what is causing the trouble
What is the error message?
below is the cfcatch details :

struct
Detail	 [empty string]
ErrNumber	 0
Message	 Variable session.email is undefined.
StackTrace	 coldfusion.runtime.UndefinedVariableException: Variable session.email is undefined. at coldfusion.runtime.CfJspPage._get(CfJspPage.java:316) at coldfusion.runtime.CfJspPage._get(CfJspPage.java:296) at coldfusion.runtime.CfJspPage._autoscalarize(CfJspPage.java:1522) at coldfusion.runtime.CfJspPage._autoscalarize(CfJspPage.java:1486) at coldfusion.compiler.ExprClassLoader.evaluate(ExprClassLoader.java:145) at coldfusion.runtime.CFPage.Evaluate(CFPage.java:2150) at cfmyfile2ecfm184893706.runPage(C:\inetpub\wwwroot\Snippets\pagination\myfile.cfm:8) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:244) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:444) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.IpFilter.invoke(IpFilter.java:64) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:449) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:112) at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:30) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94) at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:79) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at coldfusion.CfmServlet.service(CfmServlet.java:219) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:414) at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:204) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722)
Suppressed	
array [empty]
TagContext	
array
1	
struct
COLUMN	 0
ID	 CF_CFPAGE
LINE	 8
RAW_TRACE	 at cfmyfile2ecfm184893706.runPage(C:\inetpub\wwwroot\Snippets\pagination\myfile.cfm:8)
TEMPLATE	 C:\inetpub\wwwroot\Snippets\pagination\myfile.cfm
TYPE	 CFML
Type	 Expression
name	 session.email

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've requested that this question be deleted for the following reason:

Hi @gd, I am deleting this because you may be right the session is not defined anywhere but it is coming from database and i do not know why it is throwing an error, Thanks for your suggestions but that did solved the issue yet
I understand that you may not have solved why your session.email variable exists, but the question you asked IS solved.    The reason for the error is that the session.email variable does not exist.   You can fix this error by putting <cfset session.email = ""> in your onSessionStart() function or use the <cfif IsDefined()> code I posted above.

If you feel the session.email variable should already exist and it is getting lost or whatever, that's a different question.   If it is created under a different application.cfc, then that would be the reason.

I recommend accepted my first post as answer.
The Reason is i cannot define it as it is already coming from database
> The Reason is i cannot define it as it is already coming from database

Session variables don't exist in the database, but if you're saying you are creating these session variables from information provided by your database, then you can easily test to see if that is successful or not.   After that block of code, dump or test your variables:

<cfdump var="#session#">  -- will show you all the session variable created, see if session.email is among them

Or..  
<cfif NOT isDefined('session.email')>
    EMAIL IS NOT DEFINED<cfabort>
</cfif>

These may help you trouble shoot why session.email is not existing.

But as suggested, close this question and take the code from that area and post a new question we can help you with that too