>- see footer for list info -<
Do you mean someone has /Mypage.cfm?CI=23&amp;LeagueCode=MDX2004 in the
address bar? If they request that page, URL.LeagueCode won't exist.

The following should help...

<cfif StructKeyExists(url, "LeagueCode")>
        <cfif IsNumeric(RIGHT(url.LeagueCode,4))>
                <cfset request.DSN = 'fm' & RIGHT(url.LeagueCode,4)>
                <cfset request.filter = Left(url.LeagueCode, 
(Len(TRIM(url.LeagueCode))-4))>
        <cfelse>
                <cflocation url="changed.htm" addtoken="no">
        </cfif>
<cfelse>
        <!--- LeagueCode not in URL, do something about it here --->
</cfif>

Does that help any?

Ade

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 13 January 2005 10:54
To: [email protected]
Subject: [CF-Dev] Application.cfm quandary


>- see footer for list info -<
Using MX6.1 and MySQL on NT4 or XP with Apache 2.0.48.

The application has six databases, of identical structure, but a different 
one for each year (from 1998). In order to direct a query to the right 
database, and to provide the relevant league code (this is for soccer, 
BTW), the following code is used in Application.cfm:

<cfif StructKeyExists(url, "LeagueCode")>
        <cfif IsNumeric(RIGHT(url.LeagueCode,4))>
                <cfset request.DSN = 'fm' & RIGHT(url.LeagueCode,4)>
                <cfset request.filter = Left(url.LeagueCode, 
(Len(TRIM(url.LeagueCode))-4))>
        <cfelse>
                <cflocation url="changed.htm" addtoken="no">
        </cfif>
</cfif>

Any subsequent queries then use request.DSN as the datasource, and 
request.filter as a <cfqueryparam> in the WHERE clause of the SQL 
statement to filter for the right league. 

This all works fine until some bright spark tries to access a page where 
the URL is not (eg) 

/Mypage.cfm?CI=23&LeagueCode=MDX2004

but

/Mypage.cfm?CI=23&amp;LeagueCode=MDX2004

which is still a correct URL, but the subsequent query falls over with an 
error because request.DSN doesn't exist.

Can anyone suggest a way around this? I've attempted to use some form of 
Replace on the URL, but URL is a complex expression and can't be used for 
that.

Could Apache be used to change the URL to the more 'normal' form?

Cheers
Terry 
_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
>- Hosting provided by www.cfmxhosting.co.uk -<
>- Forum provided by www.fusetalk.com -<
>- DHTML Menus provided by www.APYCOM.com -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to