News by ColdFusion Cookbook

This feed does not validate. (details)

How can I delete email messages from a mail server?

18 Jul 00:05
Use <cfpop> with the action attribute set to 'delete' and the messagenumber attribute or uuid attribute set to the message you wish to delete.

How do I get the primary key of a record added to the database?

16 Jul 00:06
Many people use database tables with autonumber primary keys. These are columns (typically named "id") that the database will provide a value for by simply adding one to the last highest value. So if the last record inserted had an ID value of 5, the next will be 6. (Note that this isn't always true. You can't assume the next value will be one over the last highest value.) If you need to find out what value was used for the primary key, ColdFusion provides a simple way to do that. To use thi...

How do I get a random image from a directory?

11 Jul 00:27
Use the RandRange function to pick a random image file form your directory.

How can I store an image in a database?

8 Jul 23:11
To store an image in a database we must first turn the image in a BLOB or Binary Large OBject. Basically this is just the binary data of the image in one entity that can then be stored nice and easily in one field of a DB. Luckily CF8 comes with a little function called imageGetBlob() - below is a little example of how it can be used... First we have to use <cfimage> to create a ColdFusion image variable..

How can I send mail with ColdFusion that will not generate auto-reponsder (vacation) messages?

8 Jul 00:51
Use <cfmailparam name="Precedence" value="bulk"> or <cfmailparam name="Precedence" value="list"> after the <cfmail> tag and the email server is 'told' to avoid sending any vacation messages.

How do I mail the contents of a form?

8 Jul 00:48
One of the most common things a web site may require is a simple "Contact Us" or other form. Normally all you want to do is take the results of the form and email them to the site owner. If you want to quickly deploy a script to do this without all the fancy formatting, you can use the fact that ColdFusion treats form data as a structure. Because of this - there are some simple structure functions we can use to email the contents of the form.

How can I easily control the look and feel of my site?

4 Jul 00:55
While non-ColdFusion techniques like an effective CSS file are one way to easily control layout across a site, you also want to consider using custom tags, and custom tag "wrappers" as a way to maintain a consistent look and feel across your site. Custom tags "wrappers" are simply custom tags that wrap content. As an example: Stuff here When ColdFusion runs this file, it will execute the custom tag, foo, twice. Once before "Stuff here" and once after. ...

How can I find what machine/server my code is running on?

3 Jul 23:29
You can determine the name of the server your code is running on, as well as the ColdFusion instance that is executing it. This is very useful if you have code that you only want to execute in a development environment, or to easily tell which server in a cluster is executing your request. To retrieve the physical server name: To retrieve the ColdFusion instance:

How can I use ColdFusion to work with JSON?

2 Jul 01:09
JSON stands for JavaScript Object Notation. You can think of it as a way to represent data (and type of data) in a string. This makes the data easy to pass between the client side and the server side and is a favorite format for use with AJAX based applications. ColdFusion adds three functions that work with JSON: serializeJSON(), deserializeJSON(), and isJSON(). Let's look first at serializeJSON. You can take any arbitrary ColdFusion data and translate it into JSON using the function:

How can I read a simple text file, processing each line of the file?

1 Jul 23:38
ColdFusion makes it easy to read a file using the <cfloop> tag. By using the file attribute, you can tell <cfloop> to iterate over each line of a file.
Pages   ← previous   next
1 2 3 4 5