Solved

CFLOOP and Insert

Posted on 2008-06-23
3
434 Views
Last Modified: 2013-12-24
I have the following URL which I am parsing out the information from.

http://site.com/verifyids2.cfm?CNO=12345&id1=001&id2=002&id3=003&sn1=alastl&sn2=bflast2&sn3=clast3

I check to see if the values are valid and if not I need to insert a new record into the database. Each record needs to be insert separately. For example, the first record would insert the CNO, id1, sn1. If exists the second record would insert the s same CNO but then id2, sn2 and so on.
I have all the variables defined but I am having trouble with the loop and insert.

<cfset ids="#id1#,#id2#,#id3#" />
<cfset sns="#sn1#,#sn2#,#sn3#" />
<cfset qArray = listToArray(ids) />
<cfset aArray = listToArray(sns) />

<cfloop list="qArray" item="i">
           
     <cfquery name="AddUser" datasource="helengrace">
          INSERT INTO dbo.ib_ChildReg
(custno,IID,samplename1)
          VALUES ( '#cno#',
                                '#qArray[i]#',
                                '#aArray[i][1]#',
                                '#aArray[i][2]#',
                                '#aArray[i][3]#',);
     </cfquery>
</cfloop>
0
Comment
Question by:usky1
  • 2
3 Comments
 
LVL 14

Expert Comment

by:Scott Bennett
ID: 21868247
Your loop syntax is wrong, try it like this:
<cfloop from="1" to="#arraylen(qArray)#" index="i">
     <cfquery name="AddUser" datasource="helengrace">
          INSERT INTO dbo.ib_ChildReg (custno,IID,samplename1)
          VALUES ( '#cno#',
                                '#qArray[i]#',
                                '#aArray[i][1]#',
                                '#aArray[i][2]#',
                                '#aArray[i][3]#',);
     </cfquery>
</cfloop>

Open in new window

0
 
LVL 14

Accepted Solution

by:
Scott Bennett earned 500 total points
ID: 21868263
You query syntax is wrong as well.. use this instead:
<cfloop from="1" to="#arraylen(qArray)#" index="i">
     <cfquery name="AddUser" datasource="helengrace">
          INSERT INTO dbo.ib_ChildReg (custno,IID,samplename1)
          VALUES ( '#cno#',
                                '#qArray[i]#',
                                '#aArray[i]#');
     </cfquery>
</cfloop>

Open in new window

0
 

Author Closing Comment

by:usky1
ID: 31469893
Sorry it took awhile to get back. Thanks for your help.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Time Sheet Help 6 54
Domain Name E-mail Address & Outlook Integration 3 40
How to solve ssl error handshake failure alert on IE 1 198
app server have enough resources... 2 40
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now