Solved

Error with Evaluate Function

Posted on 2013-11-27
13
234 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
Question by:myselfrandhawa
  • 6
  • 5
13 Comments
 
LVL 39

Expert Comment

by:gdemaria
Comment Utility
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 15

Author Comment

by:myselfrandhawa
Comment Utility
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
Comment Utility
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
 
LVL 15

Author Comment

by:myselfrandhawa
Comment Utility
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
Comment Utility
What is the error message?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 15

Author Comment

by:myselfrandhawa
Comment Utility
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 500 total points
Comment Utility
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 15

Author Comment

by:myselfrandhawa
Comment Utility
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
Comment Utility
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 15

Author Comment

by:myselfrandhawa
Comment Utility
The Reason is i cannot define it as it is already coming from database
0
 
LVL 39

Expert Comment

by:gdemaria
Comment Utility
> 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now