<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>William on ColdFusion</title>
	<atom:link href="http://www.williamoncoldfusion.com/index.php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.williamoncoldfusion.com</link>
	<description>ColdFusion, the platform for business success</description>
	<pubDate>Mon, 27 Jun 2011 22:26:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Cfinclude, a primer</title>
		<link>http://www.williamoncoldfusion.com/index.php/knowledgebase/cfinclude-a-primer</link>
		<comments>http://www.williamoncoldfusion.com/index.php/knowledgebase/cfinclude-a-primer#comments</comments>
		<pubDate>Mon, 27 Jun 2011 20:30:58 +0000</pubDate>
		<dc:creator>william</dc:creator>
		
		<category><![CDATA[Knowledgebase]]></category>

		<category><![CDATA[CFinclude]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[include]]></category>

		<category><![CDATA[mappings]]></category>

		<category><![CDATA[OO]]></category>

		<guid isPermaLink="false">http://www.williamoncoldfusion.com/?p=58</guid>
		<description><![CDATA[I wanted to offer a simple primer in the use of cfincludes.  I often find that newer users can stumble on their site development when it comes to how cfincludes work in ColdFusion.
Cfincludes are probably one of the most used ColdFusion tags around.
The function of the cfinclude tag is to grab a file that [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to offer a simple primer in the use of cfincludes.  I often find that newer users can stumble on their site development when it comes to how cfincludes work in ColdFusion.</p>
<p>Cfincludes are probably one of the most used ColdFusion tags around.</p>
<p>The function of the cfinclude tag is to grab a file that is saved somewhere else in your server&#8217;s directory structure and &#8216;include&#8217; its contents in the place of the cfinclude tag.</p>
<p>So, for instance, if you have this file:</p>
<p><fieldset class="codeSample"><br />
<legend>Sample main ColdFusion file</legend><br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;cfinclude template=&#8221;/includes/head/meta.cfm&#8221; /&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
Hello World!<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
</fieldset><br />
And you have this file saved in &#8216;includes/head/meta.cfm&#8217;</p>
<p><fieldset class="codeSample"><br />
<legend>Sample main coldfusion include file</legend><br />
&lt;meta name=&#8221;keywords&#8221; content=&#8221;coldfusion,cfinclude,primer&#8221; /&gt;<br />
</fieldset><br />
Then when the page is translated for the browser by ColdFusion, it will replace the include request with the contents of the include file.</p>
<p><fieldset class="codeSample"><br />
<legend>View source from the browser</legend><br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;meta name=&#8221;keywords&#8221; content=&#8221;coldfusion,cfinclude,primer&#8221; /&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
Hello World!<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
</fieldset><br />
This is simple enough.  Hopefully you can see the benefits of having some of your code in an include file.  It makes it much easier to update a website if all of your redundant code is centralized.</p>
<p>You may have noticed that I put the include file in a specific directory structure.  This is something that I have learned helps to keep the code organized.  ColdFusion doesn&#8217;t require this level of organization, but it is helpful to yourself and other ColdFusion programmers to organize your code.</p>
<p>ColdFusion usually loads on your server with the &#8216;/&#8217; mapping already there.  This is so that you can use the &#8216;/&#8217; in your cfinclude as a mapping to your webroot, and anything after that &#8216;/&#8217; in the template parameter will be treated as the directory location.<br />
I like to add a specific mapping to my ColdFusion administrator that for my &#8216;includes&#8217; location.  This makes it possible to move the location of the includes folder for future website changes.</p>
<p>A cool feature of this is also that the mapping location of the includes folder doesn&#8217;t actually have to been inside the webroot.</p>
<p>Let&#8217;s say for instance that you have two seperate websites that use some of the same code.</p>
<p>Your web root locations might be:</p>
<p>c:/inetpub/website1</p>
<p>c:/inetpub/websiteTwo</p>
<p>then you can have a mapping to:</p>
<p>&lt;cfset this.mappings['/includes'] = &#8216;c:/sharedResources/includes&#8217; /&gt;</p>
<p>Now you would be able to use the same includes in both websites. If code changes are needed, then you would only need to change 1 location.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.williamoncoldfusion.com/index.php/knowledgebase/cfinclude-a-primer/feed</wfw:commentRss>
		</item>
		<item>
		<title>cfqueryparam &#8230; , Huh?</title>
		<link>http://www.williamoncoldfusion.com/index.php/knowledgebase/cfqueryparam-huh</link>
		<comments>http://www.williamoncoldfusion.com/index.php/knowledgebase/cfqueryparam-huh#comments</comments>
		<pubDate>Tue, 16 Jun 2009 17:20:08 +0000</pubDate>
		<dc:creator>william</dc:creator>
		
		<category><![CDATA[Knowledgebase]]></category>

		<category><![CDATA[CFqueryparam]]></category>

		<category><![CDATA[code security]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[cross site scripting]]></category>

		<category><![CDATA[Database]]></category>

		<category><![CDATA[database protection]]></category>

		<category><![CDATA[Query]]></category>

		<guid isPermaLink="false">http://www.williamoncoldfusion.com/?p=50</guid>
		<description><![CDATA[If you have been researching ColdFusion and queries on the internet, undoubtedly you have come across many a post that encourages, nay demands, that you use cfqueryparam in your queries.
The question has come up many a time regarding &#8216;when&#8217; to use it, &#8216;why&#8217; to use it, and of course &#8216;what&#8217; is it.
I will start with [...]]]></description>
			<content:encoded><![CDATA[<p>If you have been researching ColdFusion and queries on the internet, undoubtedly you have come across many a post that encourages, nay <i>demands</i>, that you use cfqueryparam in your queries.</p>
<p>The question has come up many a time regarding &#8216;when&#8217; to use it, &#8216;why&#8217; to use it, and of course &#8216;what&#8217; is it.</p>
<p>I will start with the &#8216;when&#8217;.  You should use cfqueryparam for any query to the database that uses a variable that &#8216;can&#8217; be altered by the user.  This means a url variable, a form variable, a cookie variable, etc.  I, personally, just make it a practice to use cfqueryparam for variable in the database.  (since a constant cannot be spoofed)  It may be tedious, but this little tag has saved many a website in the past from being the victim of attacks.</p>
<p>Why to use it?  Well, lets say that you have a very simple query that pulls up the data from a database to view an article on your site.  You pass that article information via the url as an id.  <br />
eg. [yoursite]/viewArticle.cfm?id=12345</p>
<p>When the &#8216;evil-bad&#8217; user tries to hack this site, they could change the url to have the id=12345;select * users;.  If your code is setup to just loop over the results they &#8216;could&#8217; see all of your user data in your users table.  Now you may be thinking to yourself, &#8216;well I don&#8217;t <i>use</i> a users table&#8217;, or &#8216;I validate my queries when they come back better than that&#8217; or something similar.  My hacking example here is very rudimentary and I am sure you can image the havoc that can be caused by changing my &#8216;hackquery&#8217; to something more vicious.  Cfqueryparam would have stopped that hack attempt in its tracks.</p>
<p>How would it stop that?  I am glad you asked.  I will try to describe this using non-technical terms to try to help anyone who is reading this, newbie or experience.</p>
<p>Imagine yourself at a drive-thru teller at your bank.  The older style where they have an actual person in a window as well as a suction tube that send your checks, cash etc into the teller to process.</p>
<p>You, in your car, are the coldfusion application code.  The teller is the database.  The tube is the datasource that you had to set up in the coldfusion administrator in order to &#8216;talk&#8217; to the database.</p>
<p>Cfqueryparam is like using those plastic canister.  You place all of your checks and your passbook and identification into the canister, you close the canister and then you place that canister into the tube and it zips off to the teller.  The teller then opens the canister, processes your request and then sends your receipts back to you.  If you had, instead, just put your items in the tube without the canister, the tube would have sent the items haphazardly to the teller.  </p>
<p>With cfqueryparam, you are telling the database that the information in the value is a &#8216;closed&#8217; environment and should only be checked against the values in the table, and NOT executed against the database as a whole.</p>
<p>I hope this helps a little to understand the when and why of cfqueryparam.  I did not include any &#8217;samples&#8217; specifically because there are plenty of resources on the internet that describe the syntax of the tag.</p>
<p>Cfqueryparam should be a single part of your overall website security schema.  It is the &#8216;last chance&#8217; before something goes to the database.  Please research full security methods to keep unwanted persons and sessions from attaching themselves to your site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.williamoncoldfusion.com/index.php/knowledgebase/cfqueryparam-huh/feed</wfw:commentRss>
		</item>
		<item>
		<title>Captcha without Cookies</title>
		<link>http://www.williamoncoldfusion.com/index.php/tips-and-tricks/captcha-without-cookies</link>
		<comments>http://www.williamoncoldfusion.com/index.php/tips-and-tricks/captcha-without-cookies#comments</comments>
		<pubDate>Tue, 16 Jun 2009 16:44:42 +0000</pubDate>
		<dc:creator>william</dc:creator>
		
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.williamoncoldfusion.com/?p=44</guid>
		<description><![CDATA[I was recently struggling with an issue dealing with a captcha method. I was testing on a browser that didn&#8217;t seem to want to persist the session information.  I had all of the information correct in the application.cfc, but it still didn&#8217;t want to do the process correctly.  To further make things worse, [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently struggling with an issue dealing with a captcha method. I was testing on a browser that didn&#8217;t seem to want to persist the session information.  I had all of the information correct in the application.cfc, but it still didn&#8217;t want to do the process correctly.  To further make things worse, I was able to get the process to run correctly in another browser.</p>
<p>With this as my muse, I decided to try to get the process  handled without using session variables, or anything that might require the existence of cookies on the browser. Please keep in mind that my solution here does not provide protection against XSRF attacks.  That will probably be covered in a future post, but solutions can also be easily researched on other blogs.</p>
<p>The only way that I could determine to do this form submission validation, without sending a cookie to the user was to either create a server variable and send the key to the form, or to directly hash the validation code in the form as a hidden field.</p>
<p>For instance:<br />
<fieldset class="codeSample"><br />
<legend>Captch Form</legend><br />
&lt;cfset validateCode = &#8220;1234&#8243;><br />
&lt;form name=&#8221;secured&#8221; method=&#8221;post&#8221; action=&#8221;&lt;cfoutput>#cgi.script_name#&lt;/cfoutput>&#8221;><br />
	&lt;cfimage action=&#8221;captcha&#8221; height=&#8221;35&#8243; width=&#8221;400&#8243; text=&#8221;#validateCode#&#8221;><br />
	&lt;input type=&#8221;text&#8221; name=&#8221;verifycode&#8221; value=&#8221;" autocomplete=&#8221;off&#8221;><br />
	&lt;input type=&#8221;hidden&#8221; name=&#8221;verifycompare&#8221; value=&#8221;&lt;cfoutput>#hash(validateCode, &#8216;SHA-256&#8242;)#&lt;/cfoutput>&#8221;><br />
	&lt;input type=&#8221;submit&#8221; name=&#8221;sendform&#8221; value=&#8221;Submit&#8221;><br />
&lt;/form><br />
</fieldset></p>
<p>This is a very simple form that will create an image, a text field, a hidden field with the hashed value of the image, and a submit button.  Obviously this is only part of a form that you would want.  Since captcha is used in much more than just login forms these days, I have slimmed this form to just the captcha portions, you would fill in the form with other fields as you need them.</p>
<blockquote><p><small>Please note, I have used an image captcha here for example purposes only.  You can use any type of captcha you like and the same principals will apply.</small></p></blockquote>
<p>After this form is submitted you will then need to process your data.<br />
<fieldset class="codeSample"><br />
<legend>Captcha Processing</legend><br />
&lt;cfif structKeyExists(form,&#8217;verifycode&#8217;) and structKeyExists(form,&#8217;verifycompare&#8217;)><br />
	&lt;cfif hash(form.verifycode, &#8216;SHA-256&#8242;) eq verifycompare><br />
		&lt;h1>Success!!&lt;/h1><br />
		&lt;cfabort><br />
	&lt;cfelse><br />
		&lt;h1>Failed!!</h1>
<p>	&lt;/cfif><br />
&lt;/cfif><br />
</fieldset></p>
<p>As you can see this is a fairly simple method of passing the data.  I would rather have preferred to keep the captcha on the session instead of revealing it to the form, but this method can be useful.</p>
<p>Now, we all know that there are a lot of ways to attack this code by submitting the form with various values in the two fields.  Captcha should never be your only form of defense against unwanted users or attacks.  I suggest you read up on:  XSRF protection, &#8216;get&#8217; injections, &#8216;post&#8217; injections, and at the very minimum, have ample use of <a href="http://www.williamoncoldfusion.com/index.php/knowledgebase/cfqueryparam-huh" title="cfqueryparam, When/Why/How">&lt;cfqueryparam></a> tags.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.williamoncoldfusion.com/index.php/tips-and-tricks/captcha-without-cookies/feed</wfw:commentRss>
		</item>
		<item>
		<title>Application.cfm vs. Application.cfc</title>
		<link>http://www.williamoncoldfusion.com/index.php/knowledgebase/applicationcfm-vs-applicationcfc</link>
		<comments>http://www.williamoncoldfusion.com/index.php/knowledgebase/applicationcfm-vs-applicationcfc#comments</comments>
		<pubDate>Sun, 10 May 2009 04:15:33 +0000</pubDate>
		<dc:creator>william</dc:creator>
		
		<category><![CDATA[Knowledgebase]]></category>

		<category><![CDATA[Application.cfc]]></category>

		<category><![CDATA[Application.cfm]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Components]]></category>

		<category><![CDATA[OO]]></category>

		<guid isPermaLink="false">http://www.williamoncoldfusion.com/?p=23</guid>
		<description><![CDATA[Many people who are using ColdFusion MX +, are unaware of the benefits of the Application.cfc pages, so have not used them.  I will endeavor to explain how an Application.cfc page can be a tremendous boon to any Enterprise level website.
Imagine this.  Everytime you open a page on your website, the Application page [...]]]></description>
			<content:encoded><![CDATA[<p>Many people who are using ColdFusion MX +, are unaware of the benefits of the Application.cfc pages, so have not used them.  I will endeavor to explain how an Application.cfc page can be a tremendous boon to any Enterprise level website.</p>
<p>Imagine this.  Everytime you open a page on your website, the Application page is run.</p>
<p>On the Application.cfm page, each line is run in sequence every time.<br />
If you load many APPLICATION variables or SESSION variables or other &#8216;environment&#8217; variables, then you are recreating them, every time you open a page on the server.  This is a lot of work for the CF server and can cause slowages on even the smallest websites.</p>
<p>On the Application.cfm page, only the code that is necessary is run.<br />
Examples:<br />
These 3 sections are common sections in an Application.cfc page.</p>
<ol>
<li>onApplicationStart</li>
<li>onSesssionStart</li>
<li>onRequestStart</li>
</ol>
<p>The &#8216;application start&#8217; is the first time an application (the website) is run on the server, or after it has timed out.  Therefore the code in the onApplicationStart section will only run at the time the website runs for the first time on the server, or after a timeout. (or reboot of the server)</p>
<p>The &#8216;session start&#8217; is the first time a unique web browser visits an application (the website), or after the session cookies have been erased.   Therefore the code in the onSessionStart section will only run at the time a web browser starts its progress through your site.</p>
<p>The &#8216;request start&#8217; is every time a page is called on the web server.  Therefore the code in the onRequestStart will always run when a new page is requested (or a page is &#8216;refreshed&#8217;)</p>
<p>There are many possible sections on the &#8216;Application.cfc&#8217; page, but the above are the most common.  Hopefully you can see how a cfc can severly reduce the stress on a coldfusion server.</p>
<p>Let&#8217;s say that you have large language files that you load into the system in order to easily change from one language to another.  In the past you might have called these variables lang.welcome = &#8216;Welcome&#8217;.  Well, you could place these language files in the application.cfc &#8211; onApplicationStart section, and only load them when the application starts.  This would reduce the overhead of lines of code that was needed to start each page.</p>
<p>You could make that into a structure:<br />
Application.lang[&#8216;en&#8217;].welcome = &#8216;Welcome&#8217;;<br />
Then in the onRequestStart you can change the &#8216;session.lang&#8217; variable based on the most recent choice of the user, and call each variable in this manner.<br />
Application.lang[session.lang].welcome.</p>
<p>This would make it so that you would only load the multitude of line of code that describe the language variables into the application scope once, but be able to call the values on each page load.</p>
<p>With an Application.cfm page, you would have to load each language file every single time you loaded the page.</p>
<p>The benefits don&#8217;t stop there.  There are a few additional &#8216;sections&#8217; of an Application.cfc page that can benefit ColdFusion developers.</p>
<p>onError is used to capture page errors and deal with them in any fashion that the developer sees fit.  This is a huge advance over the limitations of the &lt;cferror&gt; tag.</p>
<p>The onMissingTemplate section can be used to capture requests for &#8216;.cfm&#8217; pages that don&#8217;t exist (or no longer exist) on your site.  I have used this in the past to show a brief &#8216;page not found&#8217; error to the user, then display a search result of possible matches to what the user &#8216;might&#8217; have been looking for.  Certainly a whole lot better than the static &#8216;dead end&#8217; page that apache or IIS want to show the user.</p>
<p>I encourage you to have some fun testing and experimenting with the different sections of the Application.cfc page, only a few of the sections are listed here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.williamoncoldfusion.com/index.php/knowledgebase/applicationcfm-vs-applicationcfc/feed</wfw:commentRss>
		</item>
		<item>
		<title>File Uploading</title>
		<link>http://www.williamoncoldfusion.com/index.php/knowledgebase/file-uploading</link>
		<comments>http://www.williamoncoldfusion.com/index.php/knowledgebase/file-uploading#comments</comments>
		<pubDate>Fri, 08 May 2009 16:41:23 +0000</pubDate>
		<dc:creator>william</dc:creator>
		
		<category><![CDATA[Knowledgebase]]></category>

		<category><![CDATA[CFfile Upload]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://www.williamoncoldfusion.com/?p=16</guid>
		<description><![CDATA[On the boards, I often get questions regarding file uploads.  Usually these questions display a lack of knowledge about how a file is treated, and therefore sent, to the server.  I have included here a brief tutorial that I hope will help the new programmer in understanding what is happening to the file [...]]]></description>
			<content:encoded><![CDATA[<p>On the boards, I often get questions regarding file uploads.  Usually these questions display a lack of knowledge about how a file is treated, and therefore sent, to the server.  I have included here a brief tutorial that I hope will help the new programmer in understanding what is happening to the file as it travels from the user&#8217;s computer to your server.</p>
<p>First off, the form page.<br />
Try this simple form:<br />
<fieldset class="codeSample"><br />
<legend>Upload Form</legend><br />
&lt;form method=&#8221;post&#8221; action=&#8221;getfile.cfm&#8221; enctype=&#8221;multipart/form-data&#8221;><br />
 &lt;input type=&#8221;file&#8221; name=&#8221;uploadfile&#8221; size=&#8221;40&#8243; /> <br />
    &lt;input type=&#8221;submit&#8221; name=&#8221;submit&#8221; value=&#8221;Send the File Off&#8221; /><br />
&lt;/form><br />
</fieldset><br />
As you can see, this form is extremely simple.  On a real upload page you would want at minimum some instructions to the user as well as a description of what this page will be doing.</p>
<p>When a user fills out the form in their local browser and clicks on the submit button, the file will be sent automatically from the user&#8217;s computer to your server.  In the &#8216;form&#8217; tag above, the &#8216;method=post&#8217; tells the form to send all information in as a &#8216;post&#8217; form (not as part of the url string).  The &#8216;action&#8217; parameter tells the form which page to load after the form is submitted. The &#8216;enctype=multipart/form-data&#8217; tells the form that there is a file attached to the form that needs to be sent to the server (without this, the file will not be received by the server at all).</p>
<p>So, here are the steps so far:</p>
<ol>
<li>The user opens your &#8216;uploadfile.html&#8217; page in their browser. (You could have called this page anything &#8216;upload.cfm&#8217;, &#8216;uf.html&#8217;, etc)</li>
<li>The user clicks on the &#8216;browse button&#8217; in the form and chooses which file on their local computer to send to your server.</li>
<li>The user clicks on the &#8217;submit&#8217; button.</li>
<li>The file is sent with the form to your server</li>
<li>Your web server recognizes the &#8216;multipart/form-data&#8217; enctype and accepts the file, saving it in a temporary (temp) directory on the web server.</li>
<li>Your web server retrieves the &#8216;action&#8217; page (getfile.cfm, could have been called anything as long as it is a CF page) and processes it.</li>
</ol>
<p>Next, in order to actually use the file, you will need to save it into a &#8216;permanent&#8217; directory on your webserver.<br />
Try this simple CF page:</p>
<p><fieldset class="codeSample"><br />
<legend>Cffile action: Upload</legend><br />
&lt;cffile<br />
   action = &#8220;upload&#8221;<br />
   fileField = &#8220;UPLOADFILE&#8221;<br />
   destination = &#8220;#GetDirectoryFromPath(expandpath(&#8217;*.*&#8217;))#&#8221;><br />
</fieldset ><br />
This one command is both &#8216;misleading&#8217; as well as very powerful.  First the powerful part.  This command retrieves the location of the uploaded file from the current location in the temp directory.  It moves the file from the temp directory to the destination directory. and then returns to the coldfusion file a &#8216;cffile structure&#8217; filled with information about the file that was just uploaded.</p>
<p>The misleading part?  The action says &#8216;upload&#8217;.  Most people (myself included) read that to mean &#8216;upload from the users computer&#8217;.  Which can lead the programmer to believe that the file stays on the user&#8217;s computer until this command is run.  Which can also lead the programmer to believe that they have some minutia control over the user&#8217;s computer.  What the &#8216;upload&#8217; really means is &#8216;copy from temp directory&#8217; or &#8216;upload to a permanent directory&#8217;.</p>
<p>So we pick up our server activity steps from where we left off above. (web server retrieves the &#8216;action&#8217; page)</p>
<ol>
<li>Since the action page is a .cfm page the web server sends the page to the ColdFusion engine.</li>
<li>The ColdFusion engine sees the cffile upload command and;
<ul>
<li>Copies the file from the temp directory to the specified destination directory</li>
<li>If the copy was successful (no &#8216;permission&#8217; errors), then the temp directory file is deleted</li>
</ul>
</li>
<li>ColdFusion creates a structure variable called &#8216;cffile&#8217; to contain all of the information returned by the cffile action</li>
<li>After ColdFusion engine is done with the file, it is sent back to the webserver to be sent as a &#8217;static&#8217; html page to the user&#8217;s browser.</li>
</ol>
<p>This is how you upload a file from the user&#8217;s browser to a directory on your web server.  It is important to mention that this is an example of the most simple of cases.  There are other actions that you should take when uploading a file.  For instance, you should determine if you want the filename to be unique.  You should limit the file types to those types you are allowing to be uploaded.  You probably don&#8217;t want anyone to upload a .cgi, .pl, .exe, etc that may &#8216;compromise&#8217; your web server.</p>
<p>Something I would like to address, that has come up a few times, is this:<br />
A certain browser (ie) made by the same company that makes a certain popular operating system (windows) sends the user&#8217;s directory information for the file along with that file to the webserver.  You can view it by displaying the &#8216;cffile.CLIENTDIRECTORY&#8217; variable, after performing the cffile tag.  It is important not to rely on this information.  Unless you can guarantee that all browsers in your system will be IE (or at least IE7) then this information will not be available for all browsers.  The reason is due to the &#8217;sandbox&#8217; rules.  These rules are there to protect the user from web sites that might want to do too much and possibly jeopardize the user&#8217;s system.  &#8216;IE&#8217; has always broken those rules where it sees fit, but other browsers such as Netscape (now dying off), Firefox, Safari, etc respect the sandbox and don&#8217;t send that information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.williamoncoldfusion.com/index.php/knowledgebase/file-uploading/feed</wfw:commentRss>
		</item>
		<item>
		<title>Beginner Database Query Cfoutput</title>
		<link>http://www.williamoncoldfusion.com/index.php/tips-and-tricks/beginner-database-query-cfoutput</link>
		<comments>http://www.williamoncoldfusion.com/index.php/tips-and-tricks/beginner-database-query-cfoutput#comments</comments>
		<pubDate>Fri, 08 May 2009 03:18:51 +0000</pubDate>
		<dc:creator>william</dc:creator>
		
		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[Cfoutput]]></category>

		<category><![CDATA[CfQuery]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[Loop Over Query]]></category>

		<guid isPermaLink="false">http://williamoncoldfusion.com/?p=3</guid>
		<description><![CDATA[Many times on the informational boards, I come across new developers who are working with the concepts of displaying database record sets.  They are interested on how to display them in a functional way.  I have compiled a short list of different methods here where I will show you some simple solutions to [...]]]></description>
			<content:encoded><![CDATA[<p>Many times on the informational boards, I come across new developers who are working with the concepts of displaying database record sets.  They are interested on how to display them in a functional way.  I have compiled a short list of different methods here where I will show you some simple solutions to formatting your database query results.  I will offer 2 solutions for each sample.  The simple record set and the &#8216;grouped&#8217; record set.</p>
<ol>
<li> Block tags or break tags.
<p>This is probably the most familiar method to anyone entering ColdFusion.  I have shown both of these examples using the HTML paragraph tags, but you can substitute for any line-breaking code. (&lt;br />, &lt;div>&lt;/div>. etc)</p>
<p>  <fieldset class="codeSample"><br />
    <legend>Regular record set:</legend><br />
&lt;cfoutput query=&#8221;[yourqueryname]&#8221;></p>
<p>&lt;p>#[columnname]#&lt;/p></p>
<p>&lt;/cfoutput><br />
</fieldset></p>
<p><fieldset class="codeSample"><br />
    <legend>Grouped record set:</legend></p>
<p>&lt;cfoutput query=&#8221;[yourqueryname]&#8221;></p>
<p>#[sectionname]#&lt;br></p>
<p>&lt;cfoutput></p>
<p>&lt;p>#[columnname]#&lt;/p></p>
<p>&lt;/cfoutput></p>
<p>&lt;/cfoutput><br />
</legend></p>
</li>
<li>Tables - Horizontal.
<p>After working with HTML for a while you will recognize this code as a simple list/report layout.</p>
<p><fieldset class="codeSample"><br />
    <legend>Regular record set:</legend></p>
<p>&lt;table></p>
<p>&lt;cfoutput query=&#8221;[yourqueryname]&#8221;></p>
<p>&lt;tr></p>
<p>&lt;td>#[columnname]#&lt;/td></p>
<p>&lt;/tr></p>
<p>&lt;/cfoutput></p>
<p>&lt;/table><br />
</fieldset></p>
<p><fieldset class="codeSample"><br />
    <legend>Grouped record set: </legend></p>
<p>&lt;table></p>
<p>&lt;cfoutput query=&#8221;[yourqueryname]&#8221;></p>
<p>&lt;tr></p>
<p>&lt;th>#[sectionname]#&lt;/th></p>
<p>&lt;/tr></p>
<p>&lt;cfoutput></p>
<p>&lt;tr></p>
<p>&lt;td>#[columnname]#&lt;/td></p>
<p>&lt;/tr></p>
<p>&lt;/cfoutput></p>
<p>&lt;/cfoutput></p>
<p>&lt;/table><br />
</fieldset></p>
</li>
<li>Tables - Vertical.
<p>This is similar to the system above with the addition of a &#8216;counter&#8217;.  What you do is decide how many vertical results you want to display before &#8216;breaking&#8217; to the next line of results.  I have used 4 results, but choose what you need.  I have moved the &#8216;&lt;tr>&#8217; to the outside of the cfoutputs and have added a <cfif> to determine if the code should insert a table row termination and start tag. <span style="color: rgb(0, 102, 153);">I had previously left out the code that I am adding using this editing color.  I had left it out intentionally to keep the &#8216;concept&#8217; of the process simple and clear for the new developer.  It has been brought to my attention that it can end in badly formed HTML (this was the least of my concerns).</span></p>
<p></cfif></p>
<p><fieldset class="codeSample"><br />
    <legend>Regular record set:</legend></p>
<p>&lt;table></p>
<p>&lt;tr></p>
<p>&lt;cfoutput query=&#8221;[yourqueryname]&#8221;></p>
<p>&lt;td>#[columnname]#&lt;/td></p>
<p>&lt;cfif currentrow mod 4 eq 0 <span style="color: rgb(0, 102, 153);"> and currentrow neq recordcount</span>>&lt;/tr>&lt;tr>&lt;/cfif></p>
<p>&lt;/cfoutput></p>
<p>&lt;/tr></p>
<p>&lt;/table><br />
</fieldset ><br />
In the grouped example, I have added an additional cfif to check to see if the loop &#8216;did not&#8217; end on a multiple of 4 AND it is not the very first record in the query. <span style="color: rgb(0, 102, 153);">I have also added a variable that carries the row count of every breaking &lt;tr> in the data displays so that it can be checked against the currentrow in the &#8216;group&#8217; and not print two recurring breaking &lt;tr> groups together.</span><br />
<fieldset class="codeSample"><br />
    <legend>Grouped record set: </legend></p>
<p>&lt;table></p>
<p>&lt;tr></p>
<p>&lt;cfoutput query=&#8221;[yourqueryname]&#8221;></p>
<p>&lt;cfif currentrow mod 4 neq 0 and currentrow neq 1 <span style="color: rgb(0, 102, 153);"> and currentrow neq lastbreakrow </span>>&lt;/tr>&lt;tr>&lt;/cfif></p>
<p>&lt;th colspan=&#8221;4&#8221;>#[sectionname]#&lt;/th></p>
<p>&lt;/tr></p>
<p>&lt;tr></p>
<p>&lt;cfoutput></p>
<p>&lt;td>#[columnname]#&lt;/td></p>
<p>&lt;cfif currentrow mod 4 eq 0> <span style="color: rgb(0, 102, 153);"><cfset lastbreakrow="currentrow"></cfset></span>&lt;/tr>&lt;tr>&lt;/cfif></p>
<p>&lt;/cfoutput></p>
<p>&lt;/cfoutput></p>
<p>&lt;/tr></p>
<p>&lt;/table><br />
</fieldset ></p>
</li>
<li>Tables &#8211; Horizontal AND Vertical (Newspaper).
<p>This is similar to the system above however instead of running the records left to right, we will run them top to bottom for &#189; the records and then start at the top again for the 2nd half. (you can also do this for thirds, fourths, fifths, etc).</p>
<p><fieldset class="codeSample"><br />
    <legend>Regular record set:</legend></p>
<p>&lt;table></p>
<p>&lt;tr></p>
<p>&lt;td></p>
<p>&lt;cfoutput query=&#8221;[yourqueryname]&#8221;></p>
<p>#[columnname]#</p>
<p>&lt;cfif currentrow eq round(recordcount / 2)>&lt;/td>&lt;/tr>&lt;tr>&lt;td>&lt;cfelse>&lt;br />&lt;/cfif></p>
<p>&lt;/cfoutput></p>
<p>&lt;/td></p>
<p>&lt;/tr></p>
<p>&lt;/table></p>
<p></fieldset ></p>
<p><fieldset class="codeSample"><br />
    <legend>Grouped record set:</legend></p>
<p>&lt;table></p>
<p>&lt;tr></p>
<p>&lt;td></p>
<p>&lt;cfoutput query=&#8221;[yourqueryname]&#8221;></p>
<p>&lt;p>#sectionname]#&lt;/p></p>
<p>&lt;cfoutput></p>
<p>&lt;p>#[columnname]#&lt;/p><br />
<br />
&lt;cfif currentrow eq round(recordcount / 2)>&lt;/td>&lt;/tr>&lt;tr>&lt;td>&lt;/cfif></p>
<p>&lt;/cfoutput></p>
<p>&lt;/tr></p>
<p>&lt;/cfoutput></p>
<p>&lt;/table><br />
</fieldset>
</li>
</ol>
<p>This is certainly not the only methods available, nor will they be the best formatted versions for your needs, but they should hopefully help you get pointed in the right direction to have your data displayed the way you wanted it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.williamoncoldfusion.com/index.php/tips-and-tricks/beginner-database-query-cfoutput/feed</wfw:commentRss>
		</item>
	</channel>
</rss>

