Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Array Loop

    Please help me to debug:

    <cfquery name="qSelectPwd" datasource="#Application.AppDSN#">
    select password from tablename
    </cfquery>


    <!--- Create List of passowrds and array --->

    <cfset pwdlist = ValueList(qSelectPwd.password,",")>
    <cfset pwdarray = ArrayNew(1)>
    <cfset pwdarray = ListToArray(pwdlist,",")>

    <cfloop index="i" from="1" to="#ArrayLen(pwdarray)#">
    <cfoutput>#pwdarray#<br></cfoutput>
    </cfloop>

    <!--- The loop shows me different passwords. --->

    <!--- Loop for the array of passwords and convert the passwords to new
    passwords in the table --->
    <cfloop index="i" from="1" to="#ArrayLen(pwdarray)#">
    <cfquery name="qUpdate" datasource="#Application.AppDSN#">
    Update TableName
    Set password = '#Encrypt(pwdarray,Request.PasswordKey)#'
    </cfquery>
    </cfloop>

    The loop updates the table with the First Password for all the records.

    Thanks

    CFRAM Guest

  2. Similar Questions and Discussions

    1. loop through array to build a new array
      If I combine the following 2 functions (accesses by clicking a checkbox), as result the new array does not contains all items that matches the...
    2. cannot loop the array
      I have 2 questions regarding arrays: 1) we need to define the size of the array, there is no dynamic array concept? i.e. the following define the...
    3. if/loop/array question
      I'm trying to display an add or delete button dependent upon logged in user and I can't figure it out. Can someone please help with the...
    4. array data matches but array created in loop doesn't work
      I have the exact same data in two arrays, but only the array created like so will work: $spaw_imglibs = array( array( 'value' =>...
    5. loop and write array
      I'm having difficulty in trying to figure out a way to loop through a query and extract the info from a single column into an array. Here is what I...
  3. #2

    Default Re: Array Loop

    You're missing the 'where' clause in your update query. You need to qualify it
    with something like...

    Update TableName
    Set password = '#Encrypt(pwdarray,Request.PasswordKey)#'
    WHERE id =#id#;

    You may be able to do this in a single SQL statement. I'm not a SQL expert,
    but possibly someone else could suggest a way.

    btw, isn't it throwing an error? You have...

    Update TableName
    Set password = '#Encrypt(pwdarray,Request.PasswordKey)#'

    At the very least it should be...

    Update TableName
    Set password = '#Encrypt(pwdarray,Request.PasswordKey)#'


    BSterner Guest

  4. #3

    Default Re: Array Loop

    I have resolved this. Instead of using the Array Loop I used the <CFLOOP Query="FirstQuery"> and It worked.
    Thanks for the input.
    CFRAM Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139