Top 3 Products & Services


Dated: Aug. 12, 2004

Related Categories

ColdFusion Programming


ColdFusion TutorialColdfusion is a tool made from a company called Allaire, which provides a means of database to webserver communications. CFM stands for Coldfusion Management, is the extension most of the files end with. Coldfusion runs on most Windows and Solaris webservers, however it is not standard software that's installed, you will have to request it if its available, and it will cost you a bit more. The difference is you can make a standard database template, and create many dynamic pages instead of static ones, that are database driven.

Macromedia's ColdFusion is a rapid application development system. Through the use of tag-based scripting language, it enables you to build and deploy powerful application

ColdFusion, developed by Allaire (now merged with Macromedia), is a popular and sophisticated set of products for building Websites and serving pages to users. With ColdFusion, a company can build a content database using input templates and combine these with application programs to create a Website in which pages are developed dynamically as they are served. ColdFusion consists of ColdFusion Studio, which is used to build a site, and ColdFusion Server, which serves the pages to users. ColdFusion Studio is described as "a complete integrated development environment" and ColdFusion Server as "a deployment platform."


ColdFusion is A product created by Allaire Corporation of Cambridge, Mass. (in 2001, Allaire merged with Macromedia) that includes a server and a development toolset designed to integrate databases and Web pages. With ColdFusion, a user could enter a zip code on a Web page, and the server would query a database for information on the nearest movie theaters and present the results in HTML form. ColdFusion Web pages include tags written in ColdFusion Markup Language (CFML) that simplify integration with databases and avoid the use of more complex languages like C++ to create translating programs.

ColdFusion is a proven development platform for integrating browser, server and database technologies into Web applications. With the latest release, Allaire is providing scalability enhancements to support complex, large-volume sites, while maintaining a commitment to developer productivity. New scalability features include support for delivering server clusters with load balancing and fail over. New productivity features include visual programming tools, enhanced team development services and remote interactive debugging. The company has also focused on improving integration with enterprise technologies and enhancing security.


Enhanced Development Productivity

ColdFusion 5 provides new technology for rapid application development. The release includes powerful new visual programming tools for prototyping HTML pages. To enable better team development, ColdFusion 5 offers server-side source control and secure remote development for distributed teams and hosted servers. Most importantly, the new release of the ColdFusion integrated development environment, ColdFusion Studio, supports remote interactive debugging. The visual debugging tools give developers a highly productive way to analyze applications in order to identify and fix problems before they are discovered by end users.

Built-in Scalability ColdFusion 5 builds on the strength of the core application server with native support for server clusters. Using an embedded version of the award- winning BrightTiger ClusterCATS, ColdFusion 5 supports dynamic load balancing across multiple servers to deliver scalable performance. In addition, ColdFusion 5 clusters offer automatic server failover for high-availability on the most demanding e- commerce sites and corporate intranets.

Extended Technology Integration Expanding on the existing Web database integration, ColdFusion 5 includes native database drivers for Oracle and Sybase as well as support for OLE-DB. The new release adds additional support for the Extensible Markup Language (XML) and expands connectivity to distributed object technology with support for the Common Object Request Broker Architecture (CORBA). ColdFusion 5 also offers a new model for building extensions to both the core server and the visual tools, which means customers will be able to extend the product to handle a wide range of specialized needs.

Security Enhancements Enhanced security features provide developers with more flexibility and control over development and deployment. ColdFusion 5 will integrate with network operating system security including LDAP directories and Windows NT Domains, so server administrators can take advantage of existing investments in network security. The new release also includes support for server sandbox security, a feature that allows companies to host multiple secure applications on a single server.


A Comparison of PHP and ColdFusion

I actively develop in both CF and PHP, and tend to use each for their strengths.

Platform Support: CF has a relatively limited platform selection. Windows, Solaris, Linux or HP/UX. (Note, initial feedback shows that the Linux version may outperform the Windows version by as much as 150%, woo hoo!) PHP, if you can compile it, it will run.


CF is built for display code. It's scripting language is primitive and does not support standard operator syntax or user-defined functions. But, it's really fast and easy for display pages and database interaction. PHP is built to write applications. The language is strong and very flexible. Not as easy for the easy stuff, but much easier for the hard stuff.

Database Support: CF abstracts database connections, making them simple to use, and very easy to change DB platform with no code changes. (With CF I can easily develop on one database, and deploy on another.) Native DB support is only available in the Enterprise product, and limited to just a few large products. Primary DB support is through ODBC, which is fine with Windows, but is a PITA with other platforms.

PHP has extremely strong native DB support. Different DBs have different command syntax, making mid-stream database changes painful. A bit more complex to retrieve results. File-System Support: CF has adequate file support, but is quirky and not feature-rich. PHP has comprehensive file system support.

Regular Expressions: CF has a basic RegEx capability. PHP is on par with PERL for Regex. Error-handling: CF has good try/catch functionality, making formal error handling possible. PHP has no formal error handling. (This can REALLY bite! Throwing error messages to the browser is not acceptable behaviour.) What little error-handling exists is inconsistent, and many errors cannot be trapped in code at all.

Search Capability: CF is bundled with Verity, a *very* capable and feature-rich "fuzzy" search engine for both file searches and database content searches. I really miss this when working with PHP. PHP has no search capability. Date-Handling: CF will recognize just about any date format and convert on-the-fly with all date functions.

Creating a Datasource

In order to interact with a database in ColdFusion, the server must recognize a datasource. This is done by an administrator. Just ask someone with administrator privileges to create a datasource for you, then, you can be on your way to coding. The datasource is usually contained in a folder like /databases/mytutorial on the server. Creating the datasource is all of the prep work you need to do before you can code your web pages with ColdFusion.

Knowing Your Datasource's Field Names

When using ColdFusion you will be interacting with your database, so you might want to get familiar with it first. Simply writing down the tables along with their attributes could save you a lot of time in the long run. If you have ever used databases you know that there is no limit to the size, and relational databases are sometimes hard to keep track of.

Introduction to ColdFusion Interacting with Access

Simple Query

Before trying to describe anything here is a piece of code…

<CFQUERY datasource="mydb" name="Query1">

Select *

From Name_Table


Breaking down this code we see that a Query has been made. The tag <CFQUERY> is how you make queries on the database. Any SQL code that is used in Access can "almost" be copied directly to ColdFusion. Like SQL you can make WHERE commands and JOINS and the like. Below is a sample HTML document that makes a query and outputs the results.



<CFQUERY datasource="mydb" name="Query1">

Select *

From Name_Table

Where Lastname = 'Smith'


<CFOUTPUT Query="Query1">

#Firstname# #Lastname# <br>





This code simply queries the database for people with the last name "Smith" and outputs the results.

Sometimes you may want to format your output into a table so that you can use multiple columns and rows to output each record's information. Here is code to do just that.


<cfoutput query="Query1">

<table width="242" height="106">


<td height="50%">#Firstname#</td>

<td height="50%">#Lastname#</td>



<td height="50%">#SSN#</td>

<td height="50%">#DOB#</td>




This code will output a table containing someone's: Name, Social Security Number, and Date of Birth. Notice how the <CFOUTPUT> tag is wrapped around the Table. This allows ColdFusion to output every match in the Database into its own table and you only have to set the attributes for the first table. With this ability you can create innovative and creative Output/Results pages.

Intermediate Query

After mastering the basics of querying and output those results, you may need to do more complicated queries. Here is a theoretical example of a database you may encounter. The database has multiple tables and usually they are all linked to one main table. Now there may be a table that is not linked to this main table, but can still share at least one "common field." Here are the example tables.

Faculty_Table: ID, Lastname, Firstname, SSN, Campus_Affiliation, Department


Response_Table: ID, RECORD_ID, Journal_Type, Journal_Title, Date_Publicated

My notation means that a table, Faculty_Table, has columns labeled: ID, Lastname, Firstname…..etc. Response_Table shares a column with Faculty_Table, ID. The Response_Table is similar to a listing of articles a person has published. Using common sense, a person can publish more than one article in their lifetime. Therefore, each ID can be repeated throughout in Response_Table, but cannot in Faculty_Table. ID is a unique identifier in Faculty_Table, but not in Response_Table (RECORD_ID is the unique field in this case). This means a more technical query is needed. Here is the code which will query both tables, finding the records with the Lastname = 'Smith', then using this person's ID, getting all of their published articles from the Resonse_Table. A simple output is also listed.

<cfquery datasource="mydb" name="Query1">

Select Faculty_Table.*,


From Faculty_Table,


Where Faculty_Table.Lastname = 'Smith'

and Faculty_Table.ID = Response_Table.ID

Order by Response_Table.RECORD_ID


<cfoutput query="Query1">




#Lastname#, #Journal_Type#, #Journal_Title#





Cold Fusion automatically makes the associations needed and uses SQL to get these results. This comes in handy when using multiple tables and you need to get results from both of them, using the results from one, onto the other.

Sometimes when displaying results you will want to display a summary and a detailed results page. In this case you would create the summary page with a link to the detailed page. The code would look something like this.

<cfoutput query="Query1">

<a href="detailpage.cfm?RECORD_ID=#RECORD_ID#">

#View Details#



And the code in the details page will look similar to this.

<cfquery datasource="mydb" name="Query1">

Select *

From table1



Cold Fusion would take the RECORD_ID value in the link from the summary page and use it in the WHERE statement in the details page. When outputting the data from this query, you will only get the data that was stored in that RECORD_ID's row. You can send multiple parameters through the URL of the page with the "&" operator separating them. Be careful when sending secretive information like passwords, others can see them in the URL bar.

Advanced Query

Along the line you may need to insert, delete or update information in your tables. These are considered advanced and dangerous operations since they are permanent. The first one I will cover is inserting into a database.


When you insert into a database it might be information like statistics or form submissions. There are two different ways to accomplish this, but the right way depends on what your reason is for inserting. For submitting statistical data that is generated on say a results page, I recommend using the SQL method of insertion. The syntax looks like this:

<cfquery datasource="mydb" name="Query1">

Insert into stats_table(Field1, Field2, Field3)

Values('#Field1#', '#Field2#', #Field3#)


The field names are Field1, Field2, Field3 and they must exist in the table. The values must be defined, but do not have to contain any data (like a blank textfield in a form; set the default value to ""). They could be text or numbers (use single quotes for text as in above example). The other method of inserting into databases is to use the Cold Fusion tag <CFINSERT> this method uses formfields, so all data being inserted must come from a form on the previous page. The code for something like this may look like:

<cfinsert datasource="mydb" tablename="Table_Form1">

In this example, the tag will insert every field in the form, including the SUBMIT button, into the table: Table_Form1. To only insert specific fields use the parameter FORMFIELDS="Field1, Field2….." and ColdFusion will only send those field values specified.


If you were to create a site that needed to access the database and edit some field in it, you would Update the field instead of deleting and adding. This can be done in a similar way as inserting(using SQL statements or ColdFusion tags). First off the table must include some sort of primary key to uniquely identify each row. Then you need to include the primary key as one of the form fields in the previous page. Then once this is completed and only one record will definitely be changed you use the code:

<cfupdate datasource="mydb" tablename="table1">

Make sure that all fields in the previous page are in the database table or the update will not work. The SQL is similar to the insertion, just use the word update instead of insert.


Try to avoid doing this if possible. This is also done in a similar way as the above two methods, just replace with the word delete. Here is the SQL method of deleting.

<cfquery datasource="mydb" name="GetRecord">

Select *

From Table1

Where SSN= '#SSN#'


<cfquery datasource="mydb" name="Query1">

Delete from Table1

Where RECORD_ID = #GetRecord.RECORD_ID#


The above code will look for a Social Security Number that matches the parameter #SSN# and remove that person's record from the database. This statement is permanent like the others above, so a confirmation page may be needed as a secure way of doing these things.

Forms and ColdFusion

Like ASP, JSP and Frontpage Server Extensions, ColdFusion handles form data nicely. Filling form data with queries is also a task that comes in handy. If you have a listing of States, you may want to control what users type in(to prevent misspellings or invalid entries) you can create a picklist of data for the users to select from. Here is code that generated a Select box that is populated by a query.

<cfquery datasource="mydb" name="Query1">

Select ID, State

From StateTable


<select name="Location">

<option value="">None Selected

<cfoutput query="Query1">

<option value="#ID#">#State#



Similar functions can be done with putting any kind of form field inside a <CFOUTPUT> tag. Using form data you can create an even more advanced searching ColdFusion page. The form fields can contain information that users may want to search with and you can combine these fields together to get a more precise result. Here is an example of what I mean.

<form action="results.cfm" method="post">

<!-include form fields like the one above, "Location" - >

<input type="text" name="Title">


<input type="submit" name="Submit" value="Submit">


will post to this page…( I added my own comments to describe the events)

<cfquery name="Query1" datasource="mydb">

Select *

From Table1

Where Title like '%#Title#%'

//using % means Title can contain more characters than what is stored in #Title#

//Like Title="now" can return titles with "Know" or "I need it now please"

<cfif Location is not "">

//if they didn't select a location…you can't search for it.

and Location = '#Location#'



<cfoutput query="Query1">

#Title# - #Location#<br>


Inserting Form Information in to a Database

I have described before how to submit information into a database using Forms. Here is where I will describe the proper way to do this. When using forms you must be aware that Netscape and Internet Explorer do not always agree. For good measure, when you create a form field you should set its default value to "" so that Netscape does not give you problems. Also when sending information through the URL you should use the function #URLEncodedFormat(Field)# to ensure the exact wording is send to the next page. Netscape will not accept spaces in names as easily as IE does.

When using forms you may need to pass along hidden fields from one form page to another so that some data is not lost. When using hidden fields make sure to enclose a <CFOUPUT> tag around them so that ColdFusion will know to store values there. When doing certain types of databases you may need to upload files. This should not be done unless authorized to do so and should be restricted to only certain mime types like images. First here is a form that is constructed to allow file uploading.

<form ENCTYPE="multipart/form-data" method="post" action="upload.cfm">

<input type="file" name="attachedfile">


<input type="submit" name="Submit" value="Submit">


This code creates a form that allows the user to upload note the special parameter ENCTYPE. This is needed when uploading files so that the form knows it will contain file data. Here is the code to actually upload the file.

<cffile action="upload" filefield="attachedfile" destination="d:\inetpub\wwwroot\myfolder\">

To set the restriction of uploading certain filetypes look in the ColdFusion manual on how to restrict access using the parameter ACCEPT. When you upload a file ColdFusion cannot overwrite files by default. You must use the parameter NAMECONFLICT. Certain advantages to this allow you to control the naming of the files you upload. If you upload a lot of files and keep the names and location of these files in the database, it might be use to use the parameter ServerFileName. Instead of inserting the name of your file into the database, you will insert the name the server creates because of the name conflict into the database. Later when you need to retrieve the name of the file you only need to look in the database and use the filename field to view the appropriate file.

Setting up to Use Verity

In order for you to use Verity you must have an administrator create a collection for you. You are able to create the collection from ColdFusion, but an administrator should be aware that you are making the collection. The first thing you must do is index your collection. Though you may only do this once, chances are it may need to be done again so make sure you keep the file with the code in it. The code will look similar to this:

<cfindex collection="CollectionName" key="primarykey" body="Fields to Index">

This creates the collection called CollectionName. You can refer to this collection by the key field. The key field should always be the primary key or a unique identifier like a social security number. Verity will search through all of the column names you list in the body field. You must also refer to a query so that Verity knows which table from a database you want to index.

Controlling How Verity Works

After you have indexed the collection you can now search through it. In your search pages you will use the following code:

<cfsearch name="VeritySearch" collection="CollectionName" criteria="crit">

Now once you search the collection you will need to translate the results into something you can use. I use the code:

<cfset searchList = VeritySearch.key>

This line translates the results of <CFSEARCH> into a list of the key fields. Remember the key field is just a number or the primary key that can be looked up in the table. In order to query the database to return all of the fields needed you can do an additional query on the database using the results from Verity. Looking in the results from the list you created out of the Verity results will not give you much information. Doing the second query is the only way to get all data from the table. Here is the code for that.

<cfquery name="UseVerityResults" datasource="mydb">

Select *

From Name_Table

Where SSN in #searchList#


Some people will actually turn the list into an array and then step through the array. It is much easier to use the above example and just search through the list you created. This is probably the most you will have to know about Verity. You can play around with the "Criteria" field in the <CFSEARCH> tag. You can send multiple input fields through the form and link them together like the below example.


<form method="post" action="page2.cfm">

<input type="text" name="lastname">

<input type="text" name="firstname">



<cfset searchterm = "#lastname# AND #firstname#">

<cfsearch name=-"serach1" collection="Collection" criteria="searchterm">

<cfset searchList = search1.key>

<cfquery name="Query1" datasource="mydb">

Select *

From Name_Table

Where SSN in #searchList#


<cfoutput query="Query1">

#Name#, #SSN#, #Address#



Cookies and ColdFusion

Nowadays, cookies have become almost as commonplace on the Web as images or tables. And they do all kinds of stuff: They help Web designers manage user information (by storing it between site visits) and decrease the amount of overhead necessary to keep track of user information, like usernames, encrypted passwords, form variables, and shopping cart information. And they also make things easier on users by eliminating the need to log on to a site every time they visit, or making it easy to personalize content on sites. (One man's trash is another man's treasure, and now neither of them need see the other one's useless drivel.) Because cookies are so ubiquitous, they've become an essential tool; any Web developer worth his salt must be able to use them.

So you probably have a good working background on cookies already, especially since you've surely read Webmonkey's That's the Way the Cookie Crumbles and Cookies Revisited. And doubtlessly, you know how to implement cookies with PHP or JavaScript ..

Installing ColdFusion and Defining a Data Source

Installing the package is deceptively simple, and if you're an advanced enough user that some company is giving you the administrator password and letting you sit in the big kids' chair at their Web server then you shouldn't have any trouble. The reason I call the process "deceptive" is that setting this thing up is a breeze - the hard part doesn't come until later when you're building templates. The installer will ask you a few questions about where you want to put the files, what Web server software you use, what program you use to create your databases, blah blah. As before, if any of these befuddle you, you'd better go find a grown-up to be present at the proceedings. And use those little blunt scissors if you have to cut anything out.

You'll probably be asked to restart your machine and/or your Web server software. If you're not the system administrator, make sure before you restart that you have access to that little list of things you have to do to get the server back up and running (stop and restart this process, delete that route, etc.). Even the best sysadmins have these; they're usually scrawled on a Post-It affixed to the monitor. Some administrators actually print these out so they're legible, but they're usually the anal types and probably wouldn't be letting you fool with their Web server in the first place.

Now you're ready to define your data sources in ColdFusion. The newer versions of the software use a Web page interface to do this and older versions use a standard Windows dialog box. Both are found under the heading ColdFusion Administrator.

A data source name (DSN) is the database you want to serve up on the Web. If you're running your own copy of ColdFusion, you can set up several; if you're using it on a provider's machine you'll probably be limited to a single DSN. Again, the setup is pretty straightforward stuff. Just point the administrator software to the database you'll be using and, if the database resides on a machine other than the Web server, supply any log-in and password information it will need to log on to that machine. The key word here is permissions: Your database should have read access enabled for the username your Web server uses to log in. Depending on the software you use to create your databases, this may be defined in standard file permissions or in the program itself.


ColdFusion 4.0 New Features

The following list details the major new features in Allaire ColdFusion 4.0. ColdFusion Studio features are available on Windows 95/98 and Windows NT. Unless otherwise noted ColdFusion Server features are available in both the Professional and Enterprise editions on Windows and Solaris.*

Rapid Development

Integrated Development Environment

Two-way Visual Programming- Prototype and modify pages with visual HTML design tools that cleanly preserve code.

Interactive Debugger- Find and fix problems with dynamic pages using a powerful interactive visual debugger and dynamic page previewing.

Dynamic Page Quality Assurance- Validate links, HTML and CFML in dynamic pages to guarantee high quality applications.

Tag Property Inspection- Work with HTML, CFML and XML tags with configurable Tag Property inspector and navigate documents with the Tag Tree.

Extensible Wizards - Create your own wizards using XML and COM to automate common tasks and assist new developers.

Team Development Services

Server-side Source Control- Organize large scale team development with server-side source control that makes versioning and deployment easy. (Windows only)

Shared Project Management- Keep track of the files in a project no matter where they are stored by setting up independent projects and sharing them with other developers.

One-step Deployment- Deploy complex applications quickly and easily from projects to multiple servers via FTP or HTTP.

Remote Team Development - Access servers and projects remotely via HTTP with secure connections; control access to files and data sources with configurable user accounts for each developer.

Tag-based Server Scripting

Extended Scripting- CFML will be extended to support traditional scripting syntax for complex data processing on the server using branching and looping.

Structured Exception Handling- Trap and handle error messages in CFML pages that are caused by failed queries or other possible errors.

Associative Arrays- Create and manipulate n-dimensional arrays for coding sophisticated application logic and improving performance.

CASE and SWITCH Statements- Control the content of dynamic pages with conditional statements using advanced CASE and SWITCH statements.

Enhanced ColdFusion Extensions (CFX)- Create advanced XML custom tags (now called ColdFusion Extensions, CFX) that include open and close tags as well as nested tags.

Enhanced Visual Tool Extensions (VTX) - Extend ColdFusion Studio to support new CFXs and new XML vocabularies. Use VBScript or Jscript to add functionality or create macros.

Scalable Deployment

High Performance Application Delivery

Enhanced Multi-threaded Service- Rely on the multi-threaded service architecture to provide an application platform that can scale linearly with multiple processors on either Intel Win32 or SPARC Solaris.

Enhanced Page Compilation and Caching- Set ColdFusion to automatically compile and cache pages with a just-in-time optimizing compiler so they can by processed more quickly by the application server.

Static-page Caching- Cache the output of dynamic pages automatically for major performance increases on content publishing sites.

Persistent Queries - Cache results of commonly used queries to increase performance by reducing the number of database interactions.

Improved Automatic Server Recovery- Monitor and automatically restart server process in case of failures or critical errors.

Improved Thread Pooling - Enhance application performance with configurable, sophisticated thread pooling.

Server Cluster Deployment

Dynamic Load Balancing- Balance application load over multiple servers in a clustered environment to deliver very large volume sites; optimize load balancing algorithm for application servers in the cluster with remote cluster administration. (Enterprise edition only)

Automatic Server Fail Over - Guarantee high availability with automatic fail over for application servers in a cluster and rely on the software based system for no single point of failure. (Enterprise edition on Solaris only)

Open State Repository - Store client state information in shared repository in an RDBMS or in cookies to offer reliable, scalable client-state in a server cluster.

Flexible Server Administration

Administrative User Accounts - Give multiple users separate administrator accounts to limited access to server settings (Windows only).

Cluster Explorer- Use the ColdFusion ClusterCATS Explorer to manage all of the servers in a smart cluster, take servers offline for maintenance, and receive automatic email notifications of server related events. (Explorer runs on Windows NT only)

Integration with Performance Monitor - Track all of the key server metrics through the Windows NT Performance Monitor or the ColdFusion statistics utility on UNIX.



ColdFusion Application Server delivers high performance Web applications that can scale to meet the needs of high volume sites. Multi-threaded Service - Rely on the multi-threaded service architecture to provide an application platform that can scale linearly with multiple processors on either Intel Win32 or SPARC Solaris. Web Server API Support - Deliver applications with any major Web server using high performance server APIs including NSAPI, WSAPI, ISAPI and the Apache API.

Macromedia ColdFusion, is the fastest way to build and deploy powerful Web applications. Easily assemble content publishing systems, business intelligence solutions and self-service applications with an intuitive tag-based scripting language. Deliver high performance and reliability with the widely adopted, proven ColdFusion Server technology.

.Return to the top of the page

Now that you've gotten free know-how on this topic, try to grow your skills even faster with online video training. Then finally, put these skills to the test and make a name for yourself by offering these skills to others by becoming a freelancer. There are literally 2000+ new projects that are posted every single freakin' day, no lie!

Previous Article

Next Article

Jaylen's Comment
We definitely need more smart people like you arnoud.
05 Thu Jan 2012
Admin's Reply:

 Thank you Jaylen :)