Excess Characters Being Generated by ColdFusion Query/output - sql

I've got a strange issue with some Coldfusion/SQL Query output. The actual data is generating properly, but at the bottom of the page it's outputting "Library/Library/Library/Library/Library/Library/Library/Library" for no reason I can discern.
It always outputs it in exactly that format, always 8 times, no matter how many terms I'm searching for, how many records are returned, or how much text is generated after grouping.
It doesn't happen on all pages, but it does seem to happen on every page on the site that pulls a query from this database...
I'm lost. Code below, live page is here: http://www.audiogo-library.com/client/client_pages/hachettepage.cfm
<cfsetting enablecfoutputonly="yes" showdebugoutput="no">
<!--- Custom Hachette page --->
<cfset todayDate = Now()>
<!--- Link to Style Sheets --->
<img style="margin:auto" src="http://www.audiogo-library.com/Library/client/client_images/hachettelogo.gif"></br>
<cfoutput> #MonthAsString(Month(Now()))# </cfoutput> Releases</br></br>
<cfquery name="GetProductBasicInfo" datasource="#Request.Application.PowerWeb.datasource#" dbtype="odbc">
SELECT product.ProductID, productmarket.imprint, product.IsbnUpc, product.Title, product.FullTitle, product.SubTitle, product.PubDate, product.SKU, productmarket.descriptionshort, productmarket.productform, productmarket.NoOfPieces, productmarket.productmarketid
FROM Product, ProductMarket
WHERE product.productid = productmarket.productid AND product.IsbnUpc LIKE '%61113%' AND product.PubDate BETWEEN '<cfoutput>#DatePart("m", todayDate)#</cfoutput>/01/<cfoutput>#DatePart("yyyy", todayDate)#</cfoutput>' AND '<cfoutput>#DatePart("m", todayDate)#</cfoutput>/31/<cfoutput>#DatePart("yyyy", todayDate)#</cfoutput>'
ORDER BY product.FullTitle ASC
</cfquery>
<cfoutput query="GetProductBasicInfo" Group="FullTitle">
<table width="90%" border="0" style="margin-top:15px;">
<tr>
<td><p><a href="http://www.audiogo-library.com/library/productdetails.cfm?sku=#SKU#">
<cfif #FullTitle# eq ''> <div class="title"> #Title# </div>
<cfelse> <div class="title">#FullTitle# </div> </a>
</cfif></p>
<p>
<cfif #descriptionshort# neq ''> #descriptionshort# </cfif>
</p>
</td>
<td width="30%"> <img src="http://www.audiogo-library.com/library/client/Products/ProdimageLg/#SKU#.jpg"></td>
</tr>
</table>
</cfoutput>
TestText

I actually solved it by accident while trying to push the "/Library"s down the page. It turns out the cfsettings tag built into the query/output was disabling non cfoutput content. THe guy who built the footer was relying on inheriting "enablecfoutputonly='false'", and this code changed that. Everything from the site's footer was being hidden except for the section of each address that was generated by cfoutput. SO yeah, if anyone else has this or a similar problem, check your cfsettings tag, and ensure you DISABLE

Go to cfadmin and disable query caching. Restart the CF service. Voila!...no more extra data.

Related

How to pass ColdFusion cfoutput query row#/ID to another CFM or Function?

I have a Coldfusion project I'm working on and I am displaying a list of announcements that have the details truncated with this type of layout:
AnnouncmentList.cfc
<cfoutput query="qAnnouncements">
<tr>
<Td style="white-space:normal;">
#dateformat(qAnnouncements.Announcement_Send, 'ddd - mm/dd/yyyy')# <BR />
<h4>#qAnnouncements.Announcement_Title#</h4><BR />
#listFirst(wrap(qAnnouncements.Announcement_Content, 100), chr(10))#
...more<BR /><BR />
</Td>
</tr>
</cfoutput>
When I click the "...more" link, I would like a popup to display and show just the content of the announcement that is clicked. I am able to display the correct announcement on the popup by simply adjusting my qAnnouncements query display with a WHERE clause to check the Announcement_ID, but I have to hard code this in at the moment.
So how can I properly pass the qAnnouncements.Announcement_ID of the link that is clicked from the list to my AnnouncementPopup.cfc file to then use for the adjusted query?
Summary: Want to pass Announcement_ID from the in AnnouncementList.cfc -> AnnouncementPopup.cfc

How to put results of multiple querys properly in one table

<center><h2>Kaarten overzicht</h2></center>
<table border="1" id="table">
<tr>
<th>Patiente Naam</th>
<th>Arts</th>
<th>Huisarts</th>
<th>Diagnose</th>
</tr>
<!--- Alle informatie van patiente in een table zetten. --->
<cfloop query="VARIABLES.overzicht">
<cfoutput>
<tr>
<td>#Voornaam# #Achternaam#</td>
</cfoutput>
</cfloop>
<cfloop query="VARIABLES.overzichtArtsen">
<cfoutput>
<td>#Voornaam# #Achternaam#</td>
</cfoutput>
</cfloop>
<cfloop query="VARIABLES.overzichtHuisartsen">
<cfoutput>
<td>#Voornaam# #Achternaam#</td>
</cfoutput>
</cfloop>
<cfloop query="VARIABLES.overzichtDiagnose">
<cfoutput>
<td>#Type#</td>
</tr>
</cfoutput>
</cfloop>
</table>
It doesn't come out the way I wanted the results are on wrong places..
I use ColdFusion with the framework Fusebox. And the queries are SELECT * FROM [table_name];.
Please help..
#Duncan is correct about joining tables being the likely best solution, but here's an answer to your question on how to reference multiple queries in one loop.
This assumes that your queries all returned the same number of records.
<center><h2>Kaarten overzicht</h2></center>
<table border="1" id="table">
<tr>
<th>Patiente Naam</th>
<th>Arts</th>
<th>Huisarts</th>
<th>Diagnose</th>
</tr>
<!--- Alle informatie van patiente in een table zetten. --->
<cfoutput>
<cfloop query="VARIABLES.overzicht">
<tr>
<td>#Voornaam# #Achternaam#</td>
<td>
#VARIABLES.overzichtArtsen.Voornaam[CurrentRow]#
#VARIABLES.overzichtArtsen.Achternaam[CurrentRow]#
</td>
<td>
#VARIABLES.overzichtHuisartsen.Voornaam[CurrentRow]#
#VARIABLES.overzichtHuisartsen.Achternaam[CurrentRow]#
</td>
<td>
#VARIABLES.overzichtDiagnose.Type[CurrentRow]#
</td>
</tr>
</cfloop>
</cfoutput>
</table>
Queries are accessible as a struct with keys for each column, and each column is an array of values. CurrentRow is the index of the row you are currently looping over in the cfloop.
Duncan's comment about joining tables is valid, but even if you followed it, you might still have a problem because you have opening and closing tags inside different loops.
Your code start by creating a single table row with 4 cells. Then you have an opening tag inside a loop, but no closing tag. You now have malformed html which is why your display is not what you had hoped for.
It's hard to suggest alternative code because it it not entirely clear what your final output is supposed to look like.

Image is not displaying in cfdocument pdf for coldfusion 10

I am using ColdFusion 10 Enterprise edition, and am unable to display images when using CFDOCUMENT to generate a PDF. Below is the piece of code I am using:
<cfsavecontent variable="report">
<table align='center'>
<cfoutput query="VARIABLES.result">
<tr>
<td>
<div class='addInfoDetails'>#SHOWINFO#</div>
</td>
</tr>
</cfoutput>
</table>
</cfsavecontent>
In the above code, the VARIABLES.result query is coming from database and SHOWINFO is a variable having the content of image and text. For example:
SHOWINFO =
"<p> Hi This is the test information
<img alt="image" src="../TestBank/test/info/5KQ.jpg"/>
</p>"
Here if dump the SHOWINFO variable inside the CFSAVECONTENT, the image displays correctly. But when I convert this into PDF, using CFDOCUMENT, the image is not displaying.
Below is the code block I am using to generate the pdf:
<cfdocument format="PDF" saveasname="TestPDF">
<cfoutput>#report#</cfoutput>
</cfdocument>
Thanks in advance.
I fixed it by adding the attribute "localUrl = yes" in CFDOCUMENT tag.
Now it is working fine for me.
I'm saving the created pdf and find localUrl="yes" (or =true) fails. Turns out CF generating pdfs for https urls is painfully finicky.
<img src="file:\\\#replace(getCurrentTemplatePath(),"my.cfm")#images\my.png">
Worked for me, in case anyone is scraping the bottom of the barrel for ideas. getCurrentTemplatePath() gets the filename as well as the path, so I had to remove it (hence the replace(...,"my.cfm"). I also tried expandPath(".") and that failed as well.
Didn't try Dave Anderson's intriguing suggestion to grab the image Coldfusion CFDOCUMENT creates a red X

How to output variables dynamically in ColdFusion

I am trying to replace a value with a passed value using javascript or coldfusion. The idea is we have a template which outputs values in the grid. But the values displayed need be dynamically determined by a query. So far I haven't been able to come up with any good ideas.
Here is a sample of something I thought would of work (but does not). It may explain what I am trying to do:
<cfset StaticValue="DynamicValue">
<cfset DynamicValue="What I Want To Show">
<script type="text/javascript">
document.getElementById("demo").innerHTML="<cfoutput>#StaticValue#</cfoutput>";
</script>
<cfoutput>#<span id="demo"></span>#</cfoutput>
To use an existing string/variable as a variable name, you need to use bracket notation.
In CF, if you haven't explicitly scoped a variable, it is created in the Variables scope, so you can do:
<cfset StaticValue="DynamicValue">
<cfset DynamicValue="What I Want To Show">
<!--- outputs value of Variables.DynamicValue --->
<cfoutput>#Variables[StaticValue]#</cfoutupt>
(This works will all scopes/structs/queries/etc)
NOTE: If the variable is to be output inside of a JavaScript string, you need to wrap it in JsStringFormat(...) to ensure the appropriate characters are escaped.
First of all, this is wrong:
<cfoutput>#<span id="demo"></span>#</cfoutput>
You are suggesting that there is a CF variable named
<span id="demo"></span>
Your question isn't clear, so neither can be my answer, but I suspect that you are trying to do this:
<script type="text/javascript">
<cfoutput>
document.getElementById("demo").innerHTML="#StaticValue#";
</cfoutput>
</script>
<span id="demo"></span>
When this JavaScript runs on the page, the string "DynamicValue" will be written into the span#demo.
Are you trying to compare if they are the same and then display it if they are?
<cfset StaticValue="DynamicValue">
<cfif staticvalue is dynamicvalue>
<cfset DynamicValue="What I Want To Show">
<script type="text/javascript">
<cfoutput>
document.getElementById("demo").innerHTML="#DynamicValue#";
</cfoutput>
</script>
</cfif>
Not sure what u are trying to do here - as this will error on bad variable inside your # #
<cfoutput>#<span id="demo"></span>#</cfoutput>
Should be:
<cfoutput>
<span id="demo">
#dynamicvalue#
</span>
</cfoutput>
If you are just trying to get a url to display:
<cfoutput>
<span id="demo">
#dynamicvalue#
</span>
</cfoutput>

How do I grab the variable NAME and not the VALUE of the variable in ColdFusion?

The basic idea is this: I have a form that generates form fields dynamically so let's say there are 5 evens people can sign up for (they all cost $10) then those 5 evens will be displayed. Like this:
<tr>
<th><label>#SeminarWisTitle#</label></th>
<td>
<label><input type="checkbox" name="#SeminarWisID#" value="10.00" onclick="CheckChoice(this);" onfocus="startCalc();" onblur="stopCalc();" class="checkbox" /> Individual Webinar ($119)</label>
</tr>
</cfoutput>
Now because of the Javascript the value on all these events will be 10.00 but the NAME of the form field will be unique, and that is what I actaully want to store in the database.
This is the code I've written:
<cfparam name="seminarBulkSignUp_List" default="">
<cfoutput query="qSeminarWisTwo">
<cfparam name="FORM.#SeminarWisID#" default="">
<cfif #FORM[#SeminarWisID#]# neq "">
<cfset seminarBulkSignUp_List = ListAppend(seminarBulkSignUp_List, #FORM[#SeminarWisID#]#)>
</cfif>
</cfoutput>
<cfset FORM.SeminarWisTitle = #seminarBulkSignUp_List#>
So with this code, I run a query for ALL the possible events, and then just check against the form that has been submitted to see which ones are "blank" as in not selected, and the ones that are selected i want to add to a list to store in the database.
Now this works as far as letting me know which events were selected and which not, but i want the list to compile the actual FORM FIELD names not the value they have. How would I do that?
<cfoutput>
<cfloop list="#StructKeyList(FORM)#" index="thisField">
My field name: #thisField#<br/>
My field value: #FORM[thisField]#<br/>
</cfloop>
</cfoutput>
Apply as necessary.