Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Included script fails to process

Explorer ,
Mar 08, 2010 Mar 08, 2010

A homegrown banner ad script that displays banners in random order works fine when ran alone. Any of three ads will appear on the page. However, when the file is included in another using CFINCLUDE the random part fails. Only one ad appears -- apparently the one with the lowest ID.

Why would the included file behave differently? How can this be fixed?

This is CF8.

Standalone file: www.portsmouthnh.com/cfm/test.cfm and below. Reload it several times and a different ad will appear

As included: www.portsmouthnh.com/downtown/. Reload it and the same ad always appears.

(In local testing, the script works fine, but not on the server.)

I'm baffled. Any help will be appreciated.

<cfparam name="request.page" default="all">

<!--- start banner ad query --->

<!--- get ads --->

<cfif IsDefined("request.page")>

<cfquery datasource="yellowpages" name="qBannerAds" cachedwithin="#CreateTimeSpan(0,0,0,0)#">

SELECT *

FROM Ads

WHERE Page = '#Request.Page#'

AND (Show = 'yes'

AND Adtype = 'banner'

AND EndDate >= #createODBCDate(now())#)

</cfquery>

<cfif qBannerAds.RecordCount GT 0>

<!--- create a list --->

<cfset StartList = "">

<cfloop query="qBannerAds">

<cfset StartList = #ListAppend(StartList, AdID, ",")#>

</cfloop>

<!--- Get a random id --->

<cfset LengthOfList = #ListLen(StartList)#>

<cfset RandomPosition = #RandRange(1,LengthOfList)#>

<cfset RandomID = #ListGetAt(StartList, RandomPosition)#>

<!--- Select the ad --->

<cfquery datasource="yellowpages" name="qBannerAds2" cachedwithin="#CreateTimeSpan(0,0,0,0)#">

SELECT *

FROM Ads

WHERE AdID = #RandomID#

</cfquery>

<cfoutput query="qBannerAds2" maxrows="1">

<!--- create space-free name for Google Analytics tracking --->

<cfset GoogleName = #replace(Name, ' ', '_',"all")#>

<a href="#link#" onClick="javascript: pageTracker._trackPageview('/outgoing/#GoogleName#');"><img src="#image#" hspace=2 vspace=1 border=0 alt="#Name#" title="#Name#"></a> </cfoutput>

</cfif>

277
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 09, 2010 Mar 09, 2010

I'd start out by outputting your query & list data on the downtown page, hide it in a block to just your IP address. Look through the data and see if your getting the same output as you do on your local system and your test.cfm page.

Also are you using any blocking software in your firewall program or browser? Does this banner random code work in other parts of this website?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 09, 2010 Mar 09, 2010
LATEST

Thanks, but the problem had something to do with setting the request.page variable. It was different for the standalone script. On the included page the script was processing the cfelse (not shown), which needed to have the scripting for the random image added. Hard to troubleshoot when you're traveling and in a hurry ...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources