Easy CFC question (I hope)

2013-05-09 Thread Bruce Sorge

Hey,
I am doing a project for my CF class in college. I admit that I have not played 
with CFC's in a while, but I cannot figure out why this is not working:

cffunction name=adduser hint=Adds a new user to the database 
returntype=query
cfargument name=fname required=true type=string
cfargument name=lname required=true type=string
cfargument name=username required=true type=string
cfargument name=userpwd required=true type=string
cfargument name=email required=true type=string

cfset var adduser =  /
!--- Hash the password and create a random number for the URL 
on the email that will be sent ---
cfset securepwd = #hash(arguments.userpwd)# /
cfset salt = #Rand(SHA1PRNG)# /
cfset secureHash = hash(salt) /


cfquery name=qUserID result=userid 
datasource=bhsrecruitadmindsn
INSERT INTO users
(username, userpwd, fname, lname, email, secureHash)
VALUES ('#arguments.username#', '#securepwd#', 
'#arguments.fname#', '#arguments.lname#', '#arguments.email#', '#secureHash#')
/cfquery

!--- Set the auto generated key ---
cfset newID = #userid.generated_key# /
!--- Now we get the informatoion from the db ---
cfquery name=qUserEmail
SELECT fname, lname, email, secureHash
FROM users
WHERE userid = #newID#
/cfquery

cfreturn adduser
/cffunction

The information enters into the db as expected, but when I invoke the component 
on the other end:

cfinvoke method=adduser component=cfc/dbfunctions 
returnvariable=userinfo
cfinvokeargument name=username value=#form.username#
cfinvokeargument name=userpwd value=#form.userpwd#
cfinvokeargument name=fname value=#form.fname#
cfinvokeargument name=lname value=#form.lname#
cfinvokeargument name=email value=#form.email#
/cfinvoke

I get the error message The value returned from the adduser function is not of 
type query. If the component name is specified as a return type, it is possible 
that either a definition file for the component cannot be found or is not 
accessible. The error occurred on line 16.

Also, I know that there are a few things that could be fixed/tidied up 
regarding hashing and such, but this class is not on encryption or anything 
like that, it's so that the instructor see's that I have a basic understanding 
of CF. The book for the class is CFWAC for version 9, so it's beginner level 
stuff.

Bruce

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355669
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Easy CFC question (I hope)

2013-05-09 Thread morgan lindley

Change your return to:
cfretun qUserEmail

As you have it, it's attempting to return a reference to the adduser method.


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355671
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Easy CFC question (I hope)

2013-05-09 Thread Dave Watts

 cffunction name=adduser hint=Adds a new user to the database 
 returntype=query
 ...
 cfquery name=qUserEmail
 SELECT fname, lname, email, secureHash
 FROM users
 WHERE userid = #newID#
 /cfquery

 cfreturn adduser
 /cffunction

 The information enters into the db as expected, but when I invoke the 
 component on the other end:

 cfinvoke method=adduser component=cfc/dbfunctions 
 returnvariable=userinfo
 cfinvokeargument name=username value=#form.username#
 cfinvokeargument name=userpwd value=#form.userpwd#
 cfinvokeargument name=fname value=#form.fname#
 cfinvokeargument name=lname value=#form.lname#
 cfinvokeargument name=email value=#form.email#
 /cfinvoke

 I get the error message The value returned from the adduser function is not 
 of type query. If the component name is specified as a
 return type, it is possible that either a definition file for the component 
 cannot be found or is not accessible. The error occurred on line 16.

You specified that the component returns a query object in the first
line. But you're trying to return an instance of the component. You
need to change one or the other. In this case, you probably want to
change your CFRETURN to return the query object:

cfreturn qUserEmail

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355672
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Easy CFC question (I hope)

2013-05-09 Thread Bruce Sorge

Damn it. Stupid rookie mistake. 

Sent from my iPhone 4S. 

On May 9, 2013, at 11:55 AM, morgan lindley greyk...@gmail.com wrote:

 
 Change your return to:
 cfretun qUserEmail
 
 As you have it, it's attempting to return a reference to the adduser method.
 
 
 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355673
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: Easy CFC question (I hope)

2013-05-09 Thread DURETTE, STEVEN J

Actually up higher he does a cfset var adduser =  / so he is actually 
returning a variable. He can solve it either using your way or by doing a 
cfset adduser = qUserEmail / before the cfreturn.

I just mention this because if he inspected the results he wouldn't get back 
that he was returning an instance of the component, just a simple variable.

I know a lot of people who declare some sort of return variable and set it at 
the end just before returning. 

Steve

-Original Message-
From: Dave Watts [mailto:dwa...@figleaf.com] 
Sent: Thursday, May 09, 2013 11:57 AM
To: cf-talk
Subject: Re: Easy CFC question (I hope)

snip

You specified that the component returns a query object in the first
line. But you're trying to return an instance of the component. You
need to change one or the other. In this case, you probably want to
change your CFRETURN to return the query object:

cfreturn qUserEmail

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355674
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Easy CFC question (I hope)

2013-05-09 Thread Bruce Sorge

I just did what dave and morgan suggested and it worked like a charm. 
Embarrassed that I made this beginner mistake. I have about six or so more 
functions above this one that all work fine, just didn't pay attention to 
details on this one. 

Bruce
On May 9, 2013, at 12:02 PM, DURETTE, STEVEN J sd1...@att.com wrote:

 
 Actually up higher he does a cfset var adduser =  / so he is actually 
 returning a variable. He can solve it either using your way or by doing a 
 cfset adduser = qUserEmail / before the cfreturn.
 
 I just mention this because if he inspected the results he wouldn't get back 
 that he was returning an instance of the component, just a simple variable.
 
 I know a lot of people who declare some sort of return variable and set it at 
 the end just before returning. 
 
 Steve
 


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355676
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Easy CFC question (I hope)

2013-05-09 Thread Dave Watts

 Actually up higher he does a cfset var adduser =  / so he is actually 
 returning a variable. He can solve it either
 using your way or by doing a cfset adduser = qUserEmail / before the 
 cfreturn.

I didn't see that. I would recommend against creating a variable with
the same name as the component, though.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355677
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: Easy CFC question (I hope)

2013-05-09 Thread DURETTE, STEVEN J

You might want to remove the cfset var adduser =  / since it isn't used 
then. Clean code is easier to troubleshoot.

That's just my .01 (I'm too cheap to give 2 cents!) LOL.

-Original Message-
From: Bruce Sorge [mailto:sor...@gmail.com] 
Sent: Thursday, May 09, 2013 12:06 PM
To: cf-talk
Subject: Re: Easy CFC question (I hope)


I just did what dave and morgan suggested and it worked like a charm. 
Embarrassed that I made this beginner mistake. I have about six or so more 
functions above this one that all work fine, just didn't pay attention to 
details on this one. 

Bruce

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355678
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: Easy CFC question (I hope)

2013-05-09 Thread Ian Chapman

Chnage to cfreturn qUserEmail

-Original Message-
From: Dave Watts [mailto:dwa...@figleaf.com] 
Sent: 09 May 2013 16:57
To: cf-talk
Subject: Re: Easy CFC question (I hope)


 cffunction name=adduser hint=Adds a new user to the database 
 returntype=query ...
 cfquery name=qUserEmail
 SELECT fname, lname, email, secureHash
 FROM users
 WHERE userid = #newID#
 /cfquery

 cfreturn adduser
 /cffunction

 The information enters into the db as expected, but when I invoke the
component on the other end:

 cfinvoke method=adduser component=cfc/dbfunctions
returnvariable=userinfo
 cfinvokeargument name=username value=#form.username#
 cfinvokeargument name=userpwd value=#form.userpwd#
 cfinvokeargument name=fname value=#form.fname#
 cfinvokeargument name=lname value=#form.lname#
 cfinvokeargument name=email value=#form.email# 
 /cfinvoke

 I get the error message The value returned from the adduser function 
 is not of type query. If the component name is specified as a return type,
it is possible that either a definition file for the component cannot be
found or is not accessible. The error occurred on line 16.

You specified that the component returns a query object in the first line.
But you're trying to return an instance of the component. You need to change
one or the other. In this case, you probably want to change your CFRETURN to
return the query object:

cfreturn qUserEmail

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule,
and provides the highest caliber vendor-authorized instruction at our
training centers, online, or onsite.



~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355679
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Easy CFC question (I hope)

2013-05-09 Thread Bruce Sorge

Already done. And I'm stepping away from the computer or a bit. Heh. 

Sent from my iPhone 4S. 

On May 9, 2013, at 12:10 PM, DURETTE, STEVEN J sd1...@att.com wrote:

 
 You might want to remove the cfset var adduser =  / since it isn't used 
 then. Clean code is easier to troubleshoot.
 
 That's just my .01 (I'm too cheap to give 2 cents!) LOL.
 
 -Original Message-
 From: Bruce Sorge [mailto:sor...@gmail.com] 
 Sent: Thursday, May 09, 2013 12:06 PM
 To: cf-talk
 Subject: Re: Easy CFC question (I hope)
 
 
 I just did what dave and morgan suggested and it worked like a charm. 
 Embarrassed that I made this beginner mistake. I have about six or so more 
 functions above this one that all work fine, just didn't pay attention to 
 details on this one. 
 
 Bruce
 
 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355680
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Easy CFC question (I hope)

2013-05-09 Thread Mike K

Bruce I wouldn't sweat about making a rookie mistake.We all do.   Mine
is usually confusing 'eq' and '='.   as in ...

cfif variable1 eq variable2  /cfif

and

cfset variable1 = something 

I usually find out I've got them the wrong way round when I get an error
message.   You'd think something as simple as that would be easy to
remember,  if only because it trips me up so many times.But no.
So don't worry about it.   Anyway,  any programmer that tells you they
usually write code that works first time as advertised is quite probably a
liar.

What is important is to learn how you diagnose your own errors and fix them
yourself before anyone else gets involved.  You're going to keep making
mistakes,  either simply syntax mistakes or errors in code logic.The
skilled programmers learn how to look for potential minefields as they go,
and check each segment of code as they develop, so the finished code is as
robust as it's possible to be before they let anyone else test it.That
way they get the reputation of being invincible. It's all smoke and
mirrors though.   They're not invincible - they just paper over the cracks
 before anyone sees  (to mix metaphors).

Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion Enterprise, PHP, ASP, ASP.NET hosting from AUD$15/month


On Fri, May 10, 2013 at 2:12 AM, Bruce Sorge sor...@gmail.com wrote:


 Already done. And I'm stepping away from the computer or a bit. Heh.

 Sent from my iPhone 4S.

 On May 9, 2013, at 12:10 PM, DURETTE, STEVEN J sd1...@att.com wrote:

 
  You might want to remove the cfset var adduser =  / since it isn't
 used then. Clean code is easier to troubleshoot.
 
  That's just my .01 (I'm too cheap to give 2 cents!) LOL.
 
  -Original Message-
  From: Bruce Sorge [mailto:sor...@gmail.com]
  Sent: Thursday, May 09, 2013 12:06 PM
  To: cf-talk
  Subject: Re: Easy CFC question (I hope)
 
 
  I just did what dave and morgan suggested and it worked like a charm.
 Embarrassed that I made this beginner mistake. I have about six or so more
 functions above this one that all work fine, just didn't pay attention to
 details on this one.
 
  Bruce
 
 

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355681
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Easy CFC question (I hope)

2013-05-09 Thread Eric Roberts

adduser is set to ...unless i missed it, i do't see it being assigned the
return value of the query.  If you are supposed to be returning the new ID
then you would want cfreturn qUserEmail

Eric


On Thu, May 9, 2013 at 10:49 AM, Bruce Sorge sor...@gmail.com wrote:


 Hey,
 I am doing a project for my CF class in college. I admit that I have not
 played with CFC's in a while, but I cannot figure out why this is not
 working:

 cffunction name=adduser hint=Adds a new user to the database
 returntype=query
 cfargument name=fname required=true type=string
 cfargument name=lname required=true type=string
 cfargument name=username required=true type=string
 cfargument name=userpwd required=true type=string
 cfargument name=email required=true type=string

 cfset var adduser =  /
 !--- Hash the password and create a random number for the
 URL on the email that will be sent ---
 cfset securepwd = #hash(arguments.userpwd)# /
 cfset salt = #Rand(SHA1PRNG)# /
 cfset secureHash = hash(salt) /


 cfquery name=qUserID result=userid
 datasource=bhsrecruitadmindsn
 INSERT INTO users
 (username, userpwd, fname, lname, email,
 secureHash)
 VALUES ('#arguments.username#', '#securepwd#',
 '#arguments.fname#', '#arguments.lname#', '#arguments.email#',
 '#secureHash#')
 /cfquery

 !--- Set the auto generated key ---
 cfset newID = #userid.generated_key# /
 !--- Now we get the informatoion from the db ---
 cfquery name=qUserEmail
 SELECT fname, lname, email, secureHash
 FROM users
 WHERE userid = #newID#
 /cfquery

 cfreturn adduser
 /cffunction

 The information enters into the db as expected, but when I invoke the
 component on the other end:

 cfinvoke method=adduser component=cfc/dbfunctions
 returnvariable=userinfo
 cfinvokeargument name=username value=#form.username#
 cfinvokeargument name=userpwd value=#form.userpwd#
 cfinvokeargument name=fname value=#form.fname#
 cfinvokeargument name=lname value=#form.lname#
 cfinvokeargument name=email value=#form.email#
 /cfinvoke

 I get the error message The value returned from the adduser function is
 not of type query. If the component name is specified as a return type, it
 is possible that either a definition file for the component cannot be found
 or is not accessible. The error occurred on line 16.

 Also, I know that there are a few things that could be fixed/tidied up
 regarding hashing and such, but this class is not on encryption or anything
 like that, it's so that the instructor see's that I have a basic
 understanding of CF. The book for the class is CFWAC for version 9, so it's
 beginner level stuff.

 Bruce

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355682
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm