Solved

Error with Evaluate Function

Posted on 2013-11-27
13
236 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
  • 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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 500 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

785 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