Showing posts with label coldfusion. Show all posts
Showing posts with label coldfusion. Show all posts

Tuesday, June 5, 2012

Installing Coldfusion 10 on Windows 2008

When installing CF10 on 2008, you may receive on error message telling you that ASP.NET, ISAPI Extensions and ISAPI Filters needed to be installed.  Despite having these roles installed, the CF10 installer may still tell you they are not.  The little bit of information this error message leaves out is that CGI needs to be installed as well.  Once you have ASP.NET, ISAPI Extensions, ISAPI Filters AND CGI installed, the error message should go away.

Friday, April 22, 2011

Coldfusion Dynamic File Path Code

There are plenty of sites out there with this exact code and I use it in almost every site I've written, but I'll remember where it is if I post it here.

#GetDirectoryFromPath(GetCurrentTemplatePath())#
#GetDirectoryFromPath(GetCurrentTemplatePath())#somedir\somedir2\

Watch your slashes for different OS's.

Tuesday, February 23, 2010

Element CFID is undefined in SESSION

This is an issue I came across with a site hosted on a shared hosting server. The problem is a misconfiguration in the CF Admin. The solution:

1) Login to the CF Admin
2) Navigate to the Server Settings page -> Memory Variables
3) Un-check the option Use J2EE session variables
4) Check the options Enable Application Variables and Enable Session Variables
5) Submit the changes

Thursday, July 2, 2009

DSN-Less Database Connection to MySQL in Coldfusion

Have not tried this myself yet, but wanted to drop it here so we can play with it in the future.

A DSN-less connection is made completely through the code, without the need for configuring anything within the ColdFusion Administrator. All of the information for the connection is specified within the code. This includes the driver, servername, databasename, username and password.


To make a DSN-less connection to a MySQL database, the following code snippet can be used:



<cfscript>

classLoader = createObject("java", "java.lang.Class");
classLoader.forName("sun.jdbc.odbc.JdbcOdbcDriver");
dm = createObject("java","java.sql.DriverManager");

con = dm.getConnection("jdbc:odbc:DRIVER={MySQL ODBC 3.51 Driver}; SERVER=server; PORT=3306;
DATABASE=database; USER=username; PASSWORD=password;OPTION=3;");


st = con.createStatement();
rs = st.ExecuteQuery("Select * FROM table");
q = createObject("java", "coldfusion.sql.QueryTable").init(rs);

//the query is stored in the variable q


</cfscript>