![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
Hey all. I'm running a for loop that's suppose to buzz through n variables, and
I've got the variables generating and naming properly in the form, but I can't get the SQL Insert statement to submit properly. here's the code <cfquery name="addCreator" datasource="loriaville"> insert into creator ( firstName, lastName, sortInitial ) values ( 'FORM[artistFirstName#i#]', 'FORM[artistLastName#i#]', 'sortInitial#i#' ) </cfquery> The #i# variable is the index in the for loop. I don't want to use evaluate, as I hear it's a pig. Also, if anyone can provide a good tute on the fundamentals required to figure this out, I'd appreciate the help. |
| Sponsored Links |
|
|||
|
this should work:
values ( <cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM['artistFirstName' & i]#">, <cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM['artistLastName' & i]#">, <cfqueryparam cfsqltype="cf_sql_varchar" value="#variables['sortInitial' & i]#"> ) correct format for dynamic variables is #FORM['staticpart' & dynamicpart]# i am not sure where your sortInitial#i# is coming from so i used VARIABLES scope in the code above. change that to correct scope. and, yes, always use <cfqueryparam> !!! hth Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ |
|
|||
|
Hey Azadi. That worked great. I had a few other adjustments to make (other
areas where I had to use the same dynamic variable creation for initialization) I'm wondering if you or anyone else now can point me in the right direction on what topic this would fall under (just so I can brush up on this so it's more natural). Regardless, thanks again for your help! It's working! ![]() |
|
|||
|
glad i could help!
other than CFWACK, CFML reference and CF Dev Guide, i am afraid i can't suggest any direct sources for more info. this form of notation: SCOPENAME['variablename'] is called associative array notation. googling this may point you to more info... Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ |
|
|||
|
[q]Originally posted by: hannibalcanibal
Hey Azadi. That worked great. I had a few other adjustments to make (other areas where I had to use the same dynamic variable creation for initialization) I'm wondering if you or anyone else now can point me in the right direction on what topic this would fall under (just so I can brush up on this so it's more natural). Regardless, thanks again for your help! It's working! ![]() [/q] Answering questions on this forum is a great way to increase your knowlege. It exposes you to other people's answers. It's how I learned array notation. |
|
|||
|
[q]Originally posted by: Dan Bracuk
[Q]Originally posted by: hannibalcanibal Hey Azadi. That worked great. I had a few other adjustments to make (other areas where I had to use the same dynamic variable creation for initialization) I'm wondering if you or anyone else now can point me in the right direction on what topic this would fall under (just so I can brush up on this so it's more natural). Regardless, thanks again for your help! It's working! ![]() [/Q] Answering questions on this forum is a great way to increase your knowlege. It exposes you to other people's answers. It's how I learned array notation.[/q] Hey Azadi. "associative array notation"...that's the term I couldn't think of...fantastic. Thx once again. Hey Dan. I totally agree. I've never really done it before cause it seems theres always someone who knows way more than I, and I never want to point people in the wrong direction due to my inexperience, but to sum it up, I'm going to start doing exactly that in the evenings I think. Thanks for the extra push in the right direction. ![]() |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise