Adobe Dreamweaver Forums



Last 10 THreads :         Capture full URL with CF CGI variable (Last Post : Azadi - Replies : 2 - Views : 3 )           »          Centering a site using layers in browser window (Last Post : malcster2 - Replies : 2 - Views : 3 )           »          Flash/Flex Shopping Carts - A flawed concept ? (Last Post : gazmcghee - Replies : 5 - Views : 20 )           »          Open SWF from another SWF in new Flash Player (Last Post : Jimmy M - Replies : 0 - Views : 1 )           »          How do I open te files in older versions of Director? (Last Post : thaisdoro - Replies : 0 - Views : 1 )           »          Load .exe file into Flash (Last Post : FlashJester Support Team - Replies : 1 - Views : 3 )           »          Create a link to open a .exe file (Last Post : FlashJester Support Team - Replies : 1 - Views : 2 )           »          Change html page image by the month (Last Post : malcster2 - Replies : 9 - Views : 10 )           »          Updated page not visible in IE (Last Post : aterrill - Replies : 6 - Views : 7 )           »          Tabbed pages question (Last Post : Dooza - Replies : 4 - Views : 5 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Cold Fusion
 
Tags:



Reply
  #1 (permalink)  
Old 10-07-2008, 02:53 AM
hannibalcanibal
 
Posts: n/a
Diggs:
Default Dynamic SQL FORM Variable

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.




Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-07-2008, 03:00 AM
Azadi
 
Posts: n/a
Diggs:
Default Re: Dynamic SQL FORM Variable

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/
Reply With Quote
  #3 (permalink)  
Old 10-07-2008, 04:49 AM
hannibalcanibal
 
Posts: n/a
Diggs:
Default Re: Dynamic SQL FORM Variable

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!



Reply With Quote


  #4 (permalink)  
Old 10-07-2008, 05:03 AM
Azadi
 
Posts: n/a
Diggs:
Default Re: Dynamic SQL FORM Variable

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/
Reply With Quote
  #5 (permalink)  
Old 10-07-2008, 05:28 PM
Dan Bracuk
 
Posts: n/a
Diggs:
Default Re: Dynamic SQL FORM Variable

[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.

Reply With Quote
  #6 (permalink)  
Old 10-07-2008, 05:30 PM
hannibalcanibal
 
Posts: n/a
Diggs:
Default Re: Dynamic SQL FORM Variable

[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.

Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:13 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk