Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

output from ListRest(GetAuthUser()) function not working as I expected

New Here ,
May 10, 2008 May 10, 2008
I am using the <cflogin> function to log users into the site.
My code reads as follows:
<cflogin
<cfloginuser
name="sNameVariable1, sNameVariable2"
password="sPasswordVariable"
roles="sRolesVariable">
</cflogin>
This works fine. The user can login, and using the ListFirst(GetAuthUser()) and ListRest(GetAuthUser()), I can view and assigning these values to variables, I can view the values using the cfdump function.
Example
<cfset sUserFirstName = ListFirst(GetAuthUser())>
<cfset sUserID = ListRest(GetAuthUser())>
<cfoutput><cfdump var="#sUserID#"></cfoutput>
The value held in the sUserID variable is a value created by the CreateUUID() function in the INSERT statement of my user registration page for creating a user ID.
When I use the sUserID in the WHERE section of a query SELECT statement, however, the recordset returned has no data.
Example
SELECT sUserFirstName, sUserLastName
FROM hsprovider
WHERE providerID = '#sUserID#'

but, when I use the literal string that should be held in sUserID, I get the correct recordset. ie
SELECT sUserFirstName, sUserLastName
FROM hsprovider
WHERE providerID = 'STUEVEEXC-DVXTHYY54-DSFK345-ETC-ETC-ETC'

The output is what I want. I have tried various syntax changes in the where statement, with no positive affect. What am I doing wrong? Thanks so much in advance--daniel
TOPICS
Getting started
409
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 10, 2008 May 10, 2008
getauthuser() function returns the NAME of authenticated user,
specifically, the NAME passed to <cfloginuser> tag.

i am thus assuming you are passing the userID as part of NAME attribute
to cfloginuser tag.

now look at what you are passing as NAME to your cfloginuser tag:
name="sNameVariable1, sNameVariable2"

see it? see the SPACE after the comma? all cf list functions, including
listrest() assume a COMMA as default list delimiter. thus
listrest(getauthuser()) will return "[SPACE]userID". that is why it does
not work in your sql WHERE clause

several options you have here to work around it:
1) declare a custom delimiter in your listrest() calls:
listrest(getauthuser(), ", ")

2) use trim(listrest(...)) to trim the whitespace

hth


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 11, 2008 May 11, 2008
LATEST
thanks so much--explanation very precise. dan
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources