10 Replies - 2949 Views - Last Post: 07 June 2011 - 02:59 PM Rate Topic: -----

#1 ProdicalProgrammer  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 115
  • Joined: 26-June 09

< marks the beginning of a ColdFusion tag.Did you mean LT or LTE?

Posted 06 June 2011 - 06:26 AM

Hi Guys

This is my code.

Im not entirely sure why im getting this error.

Can anybody point me in the right direction.

here is the error.

nvalid CFML construct found on line 3 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:\ColdFusion9\wwwroot\practice\login.cfc: line 3

 <cfparam name="FORM.EMAIL" default="">
 <cfparam name="FORM.PASSWORD" default="">
 <cfcomponent>
 	<cffunction name="get_user" returntype="query">
		<cfquery name="login" datasource="#application.db#">




<cfparam name="Form.submit" default="">
<cfparam name="Form.email" default="">
<cfparam name="Form.password" default="">

<cfif form.submit eq "Submit">
<cfinvoke component="login" method="get_user" returnvariable="SID">
</cfif>


<cfform method="post">
Email address<br>
<cfinput type="text" name="FORM.EMAIL" required="yes" message="Please insert an email"><br><br>
Password<br>
<cfinput type="password" name="FORM.PASSWORD" required="yes" message="Please enter password">
<br><br>
<cfinput type="hidden" value="#FORM.EMAIL#" name="FORM.EMAIL">
<cfinput type="hidden" value="#FORM.PASSWORD#" name="FORM.PASSWORD">
<cfinput type="submit" value="Submit" name="Submit">

</cfform>



My CFC component
<cfparam name="FORM.EMAIL" default="">
<cfparam name="FORM.PASSWORD" default="">
<cfcomponent>
	<cffunction name="get_user" returntype="query">
		<cfquery name="login" datasource="#application.db#">
        	SELECT * FROM tblsubscribers
            WHERE FORM.EMAIL = SUBEMAIL and FORM.PASSWORD = SUBPASSWORD
        </cfquery>
		<cfreturn SID>
	</cffunction>
</cfcomponent>



Is This A Good Question/Topic? 0
  • +

Replies To: < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1926
  • View blog
  • Posts: 3,471
  • Joined: 13-January 08

Re: < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?

Posted 06 June 2011 - 06:41 AM

I can see several things you need to fix...but I'm not seeing the bit of offending code that's throwing the error.

Normally that kind of error happens when you're trying to do a SQL "less than" comparison in a where statement contained in a CFQUERY tag block...but I'm not seeing such in what you posted.

Post login.cfc in it's entirety and perhaps we can see what happened.
Was This Post Helpful? 0
  • +
  • -

#3 ProdicalProgrammer  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 115
  • Joined: 26-June 09

Re: < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?

Posted 06 June 2011 - 06:46 AM

Ok perhaps its the other errors that i do have any pointers to go in the right direction?
Was This Post Helpful? 0
  • +
  • -

#4 xheartonfire43x  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 454
  • Joined: 22-December 08

Re: < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?

Posted 06 June 2011 - 07:55 AM

That is a terrible error for what is really happening, but what you need to remember is that nothing can go outside of cfcomponent tags. Right now you have a few params outside of your component tags. Change you component to:

<cfcomponent>
        <cfparam name="FORM.EMAIL" default="">
        <cfparam name="FORM.PASSWORD" default="">
	<cffunction name="get_user" returntype="query">
		<cfquery name="login" datasource="#application.db#">
        	SELECT * FROM tblsubscribers
            WHERE FORM.EMAIL = SUBEMAIL and FORM.PASSWORD = SUBPASSWORD
        </cfquery>
		<cfreturn SID>
	</cffunction>
</cfcomponent>



Mind you that is a terrible way to do this. For data access like this you really don't want to pull in scoped variables like you are doing. Instead you should pass in the values like this:

<cfcomponent>
 
	<cffunction name="get_user" returntype="query">
                <cfargument name="email" type="string" required="true" default="" />
                <cfargument name="password" type="string" required="true" default="" />
                <cfset var login = '' />
		<cfquery name="login" datasource="#application.db#">
        	       SELECT sid FROM tblsubscribers
                       WHERE SUBEMAIL = <cfqueryparam value="#Arguments.email" cfsqltype="cf_sql_varchar" /> and SUBPASSWORD = <cfqueryparam value="#Arguments.password#" cfsqltype="cf_sql_varchar" />
                </cfquery>
		<cfreturn login.SID>
	</cffunction>
</cfcomponent>



Then when you call your function you can either use the cfinvoke tag or the createObject function.

[code]<!--- Example using the cfinvoke tag --->
<cfinvoke component="mycomponent" method="get_login" returnvariable="sid">
<cfinvokeargument name="email" value="#Form.email#" />
<cfinvokeargument name="password" value="#Form.password#">
</cfinvoke>
<cfscript>
// Using object instantiation
myobject = createObject('component','mycomponent');
sid = myobject.get_user(email=Form.email, password=Form.password);
</cfscript>

Because you are new to ColdFusion, let me suggest a couple of books to you. The first one is each volume of the ColdFusion Web Application Construction Kit (Commonly called CFWACK in the community). CFWACK is an awesome resource for ColdFusion developers, teach skills from beginner to advanced. I would suggest buying the CFWACK book for your CF server? A lot has changed between CF 6,7,8 and 9.

The other book is Object-Oriented Programming in ColdFusion by Matt Gifford. It is a fantastic resources for OOP, which is quickly becoming the primary development in ColdFusion.

This post has been edited by xheartonfire43x: 06 June 2011 - 08:06 AM

Was This Post Helpful? 2
  • +
  • -

#5 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1926
  • View blog
  • Posts: 3,471
  • Joined: 13-January 08

Re: < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?

Posted 06 June 2011 - 08:10 AM

View PostProdicalProgrammer, on 06 June 2011 - 09:46 AM, said:

Ok perhaps its the other errors that i do have any pointers to go in the right direction?


Well, xheartonfire43x mentioned one thing to change. However, there are quite a few more. For instance:
<cfparam name="FORM.EMAIL" default="">
<cfparam name="FORM.PASSWORD" default="">
<cfcomponent>
    <cffunction name="get_user" returntype="query">
        <cfquery name="login" datasource="#application.db#">
            SELECT * FROM tblsubscribers
            WHERE FORM.EMAIL = SUBEMAIL and FORM.PASSWORD = SUBPASSWORD
        </cfquery>
        <cfreturn SID>
    </cffunction>
</cfcomponent>



You see the WHERE statement in your query? For that to work the way you've written it there, you'd have to have columns in your tblsubscribers table called "FORM.EMAIL" and "FORM.PASSWORD" respectively. What's more, you're equating the table column contents to an equivalency of "SUBEMAIL" and "SUBPASSWORD" that I don't see defined anywhere. I'm guessing you have them turned around though and if so, you're query would need to look like this:
<cfquery name="login" datasource="#application.db#">
   SELECT * FROM tblsubscribers
   WHERE SUBEMAIL = <cfqueryparam value="#FORM.EMAIL#" cfsqltype="cf_sql_varchar"> 
      and SUBPASSWORD = <cfqueryparam value="#FORM.PASSWORD#" cfsqltype="cf_sql_varchar">
</cfquery>


However, back to your original question about the error you're seeing, post up the code for your login.cfc and let's see what you're doing.

This post has been edited by Craig328: 06 June 2011 - 08:11 AM

Was This Post Helpful? 1
  • +
  • -

#6 xheartonfire43x  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 454
  • Joined: 22-December 08

Re: < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?

Posted 06 June 2011 - 12:36 PM

Craig328, that CFC code posted does seem to be login.cfc. I have tested and that is in fact the error returned when placing param's outside of the cfcomponent tag.

This post has been edited by xheartonfire43x: 06 June 2011 - 12:37 PM

Was This Post Helpful? 1
  • +
  • -

#7 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1926
  • View blog
  • Posts: 3,471
  • Joined: 13-January 08

Re: < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?

Posted 06 June 2011 - 12:39 PM

Really? That now makes what you said earlier make perfect sense: "terrible error for what is really happening".

Ya!y Adobe for the nonsensical error messages! If there's one thing I could change about that product it'd definitely be the error messaging/debugging.
Was This Post Helpful? 1
  • +
  • -

#8 ProdicalProgrammer  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 115
  • Joined: 26-June 09

Re: < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?

Posted 06 June 2011 - 11:14 PM

Hi Guys.

Thank you so much for the assistance.

I am trying to teach myself CFC`s.

You guys really helped.

I did google to see if i was able to put a cfparam in component.

It said yes but not where to put it thats why I was baffeled as to why i was receiving the error.

Anyways you guys helped tremendously i am now receiving errors that I know how to handle thanks again guys.
Was This Post Helpful? 0
  • +
  • -

#9 xheartonfire43x  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 454
  • Joined: 22-December 08

Re: < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?

Posted 07 June 2011 - 07:58 AM

View PostCraig328, on 06 June 2011 - 03:39 PM, said:

Really? That now makes what you said earlier make perfect sense: "terrible error for what is really happening".

Ya!y Adobe for the nonsensical error messages! If there's one thing I could change about that product it'd definitely be the error messaging/debugging.


Craig, the problem may not necessarily be Adobe on it's own, but the fact that it is sitting on Java. I will say that some error messages are awful at saying what is actually happening, but sometimes it's not Adobe's (or Railo's or BlueDragon's) fault. I ran into an error the other day that ended up being ORM. The error message was the most vague, nondescript error in the world.


View PostProdicalProgrammer, on 07 June 2011 - 02:14 AM, said:

Hi Guys.

Thank you so much for the assistance.

I am trying to teach myself CFC`s.

You guys really helped.

I did google to see if i was able to put a cfparam in component.

It said yes but not where to put it thats why I was baffeled as to why i was receiving the error.

Anyways you guys helped tremendously i am now receiving errors that I know how to handle thanks again guys.


Again, let me strongly suggest the books I talked about above. I would strongly suggest CFWACK, since you seem very new to ColdFusion. Once you familiarize yourself with it a bit more and you want to take the next step pick up OOP in ColdFusion. It is an awesome book for learning Object Oriented Programming concepts (basically the reason for using CFCs) in the context of Coldfusion.
Was This Post Helpful? 1
  • +
  • -

#10 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1926
  • View blog
  • Posts: 3,471
  • Joined: 13-January 08

Re: < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?

Posted 07 June 2011 - 08:58 AM

I suppose there's some measure of truth in the whole "it runs on top of Java" thing...but if they can catch not closing out a cfif block, they can catch putting anything outside of cfcomponent. It is indeed Java but all that means is that they could have written appropriate Java error handling and filter it back through the CF server to give you a much better idea of what broke than they do for many things now.

In other words, all the errors happen in Java...they've coded appropriate error handling for most but not all of them though.

Good catch though. I saw that and went "that's not the way I'd do it...but hey, I don't know everything" so I didn't consider it as the error especially given the error message CF did return.
Was This Post Helpful? 0
  • +
  • -

#11 xheartonfire43x  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 454
  • Joined: 22-December 08

Re: < marks the beginning of a ColdFusion tag.Did you mean LT or LTE?

Posted 07 June 2011 - 02:59 PM

In all fairness you should take a look at Ruby on Rails errors. Most all of them just say "Syntax error."

I do agree that they should have put better error handling in. Perhaps asking for the communities help in finding errors that aren't properly handled might be a good solution to that for Adobe.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1