Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Processing LT in ColdFusion

Tags:

coldfusion

I am writing my first ColdFusion component but I am getting this error. Does anyone have an idea what this means?

Invalid CFML construct found on line 2 at column 1.
ColdFusion was looking at the following text:
<
The CFML compiler was processing:
< marks the beginning of a ColdFusion tag.Did you mean LT or LTE?
The error occurred in C:/inetpub/wwwroot/ColdFusion/test.cfm
<cfcomponent displayname="News" hint="Get News">
<cffunction name="GetNews" returntype="query">
<cfquery datasource="CFDatabase" name="myQuery"

The source code:

<cfcomponent displayname="News" hint="Get News">
<cffunction name="GetNews" returntype="query">
    <cfquery datasource="CFDatabase" name="myQuery">
        select * from tbNews
    </cfquery>
    <cfreturn myQuery>
</cffunction>
</cfcomponent>

<cfinvoke component="components.News" method="GetNews" returnvariable="AllNews">

<table width="100%">
<cfoutput query="AllNews">
<tr>
    <td>Title:</td>
    <td><cfoutput>#myQuery.Title#</cfoutput></td>
    <td>Body:</td>
    <td><cfoutput>#myQuery.Description#</cfoutput></td>
</tr>
</cfoutput>
</table>
like image 841
TheMonkeyMan Avatar asked Nov 13 '12 10:11

TheMonkeyMan


1 Answers

You've placed the <cfcomponent> inside a cfm file, this i not allowed.

move the <cfcomponent> block to a file with a .cfc extension (eg News.cfc), then call it from your .cfm file

in News.cfc

<cfcomponent>
<cffunction name="getNews">
...
</cffunction>
</cfcomponent>

in test.cfm

<cfset newsObj = createobject('component', 'News')>
<cfset AllNews = newsObj.getNews()>
like image 127
Chris Blackwell Avatar answered Sep 30 '22 23:09

Chris Blackwell