Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error with Evaluate Function

Posted on 2013-11-27
13
Medium Priority
?
245 Views
Last Modified: 2013-12-29
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.
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
13 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 39680826
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>
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39680957
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
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 39681076
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.
0
Implementing Azure Infrastructure Exam 70-533

This course is designed to familiarize and instruct students in the content that is covered by Microsoft Exam 70-533, Implementing Microsoft Azure Solutions. It focuses on all the November 2016 objective domain topics.

 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39681123
That is my guess too. but al variables have been defined, not sure what is causing the trouble
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 39681143
What is the error message?
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39681159
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

0
 
LVL 39

Accepted Solution

by:
gdemaria earned 2000 total points
ID: 39681219
Just as I thought, the error is that the variable is undefined:

Variable session.email is undefined


Did you try my code and test it?   The variable is not defined.
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39716838
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
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 39716839
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.
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 39718331
The Reason is i cannot define it as it is already coming from database
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 39721974
> 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
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question