| Subject: | Re: Easy <cftry> question |
|---|---|
| From: | "nettlesd1995" <webforumsuser@xxxxxxxxxxxxxx> |
| Date: | Tue, 29 Jul 2008 13:57:57 +0000 (UTC) |
| Newsgroups: | macromedia.coldfusion.cfml_general_discussion |
Dan,
Maybe you can explain something to me. When I tried using <cflocation> as you
suggested, my errors don't show up. They only show up when using <cfinclude>
so that's why I use that particular statement.
[b]This doesn't work:[/b]
<cfset foundDatabaseError = "No">
<cftry>
<cfquery name="">
</cfquery>
<cfcatch type="any">
<cfset foundDatabaseError = "Yes">
</cfcatch>
</cftry>
<cfif foundDatabaseError equal "Yes">
<cfset session.errors[1] = "Database Connection error.">
<cflocation url="index.cfm">
<cfabort>
</cfif>
[b]This works:[/b]
<cfset foundDatabaseError = "No">
<cftry>
<cfquery name="">
</cfquery>
<cfcatch type="any">
<cfset foundDatabaseError = "Yes">
</cfcatch>
</cftry>
<cfif foundDatabaseError equal "Yes">
<cfset session.errors[1] = "Database Connection error.">
<cfinclude template="index.cfm">
<cfabort>
</cfif>
[b]Application.cfm[/b]
some start code
.
.
.
<cfif not IsArray("session.errors")>
<cfset session.errors = ArrayNew(1)>
</cfif>
.
.
some end code
[b]Index.cfm[/b]
some start code
.
.
.
<cfoutput>
<cfif not ArrayIsEmpty(session.errors)>
<cfloop index="loopCounter" from="1" to="#ArrayLen(session.errors)#">
<tr>
<td id="red">#session.errors[loopCounter]#</td>
</tr>
</cfloop>
<cfset clearErrors = ArrayClear(session.errors)>
<cfelse>
<tr>
<td> </td>
</tr>
</cfif>
</cfoutput>
.
.
.
some end code
I've tried the above code several times and the session.errors will only show
up when doing a <cfinclude> statement and not a <cflocation> statement. Why is
that?
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: pass query result as parameter to javascript, Dan Bracuk |
|---|---|
| Next by Date: | Re: Response time is very high, Markiv@cfml |
| Previous by Thread: | Re: Easy <cftry> question, Adam Cameron |
| Next by Thread: | Detect image type, idesdema |
| Indexes: | [Date] [Thread] [Top] [All Lists] |