Troubleshooting common problems



A few common problems that you might encounter and ways to resolve them are described here.

For more information on troubleshooting ColdFusion, see the ColdFusion Support Center Testing and Troubleshooting page at www.adobe.com/go/learn_cfu_troubleshoot_en. For common tuning and precautionary measurements that can help you prevent technical problems and improve application performance, see the ColdFusion tech tips article, TechNote number 13810. A link to the article is located near the top of the Testing and Troubleshooting page.

CFML syntax errors

Problem: You get an error message such as the following:

Encountered "function or tag name" at line 12, column 1. 
Encountered "\"" at line 37, column 20.  
Encountered "," at line 24, column 61.  
Unable to scan the character '\"' which follows "" at line 38, column 53. 

These errors typically indicate that you have unbalanced <, ", or # characters. One of the most common coding errors is to forget to close quoted code, number sign-delimited variable names, or opening tags. Make sure the code in the identified line and previous lines do not have missing characters.

The line number in the error message often does not identify the line that causes the error. Instead, it identifies the first line where the ColdFusion compiler encountered code that it could not handle as a result of the error.

Problem: You get an error message you do not understand.

Make sure all your CFML tags have matching end tags where appropriate. It is a common error to omit the end tag for the cfquery, cfoutput, cftable, or cfif tag.

As with the previous problem, the line number in the error message often does not identify the line that causes the error, but the first line where the ColdFusion compiler encounters code that it could not handle as a result of the error. Whenever you have an error message that does not appear to report a line with an error, check the code that precedes it for missing text.

Problem: Invalid attribute or value.

If you use an invalid attribute or attribute values, ColdFusion returns an error message. To prevent such syntax errors, use the CFML Code Analyzer. Also see Using the cftrace tag to trace execution.

Problem: You suspect that there are problems with the structure or contents of a complex data variable, such as a structure, array, query object, or WDDX-encoded variable.

Use the cfdump tag to generate a table-formatted display of the variable’s structure and contents. For example, to dump a structure named relatives, use the following line. Surround the variable name with number signs (#).

<cfdump var=#relatives#>

Data source access and queries

Problem: You cannot make a connection to the database.

Create the data source before you can connect. Connection errors can include problems with the location of files, network connections, and database client library configuration.

Create data sources before you refer to them in your application source files. Verify that you can connect to the database by clicking the Verify button on the Data Sources page of the ColdFusion Administrator. If you are unable to make a simple connection from that page, you might need to consult your database administrator to help solve the problem.

Also, check the spelling of the data source name.

Problem: Queries take too long.

Copy and paste the query from the Queries section of the debugging output into the query analysis tool of your database. Then retrieve and analyze the execution plan generated by the query optimizer of the database server. (The method for doing this varies from dbms to dbms.) The most common cause of slow queries is the lack of a useful index to optimize the data retrieval. In general, avoid table scans (or "clustered index" scans) whenever possible.

HTTP/URL

Problem: ColdFusion cannot correctly decode the contents of your form submission.

The method attribute in forms sent to the ColdFusion server must be Post, for example:

<form action="test.cfm" method="Post">

Problem: The browser complains or does not send the full URL string when you include spaces in URL parameters.

Some browsers automatically replace spaces in URL parameters with the %20 escape sequence, but others might display an error or just send the URL string up to the first character (as does Netscape 4.7).

URL strings cannot have embedded spaces. Use a plus sign (+) or the standard HTTP space character escape sequence (%20), wherever you want to include a space. ColdFusion correctly translates these elements into a space.

A common scenario in which this error occurs is when you dynamically generate your URL from database text fields that have embedded spaces. To avoid this problem, include only numeric values in the dynamically generated portion of URLs.

Or, you can use the URLEncodedFormat function, which automatically replaces spaces with %20 escape sequences. For more information on the URLEncodedFormat function, see the CFML Reference.