ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old March 29th, 2005, 05:46 PM
samb1 samb1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 67 samb1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 42 m 42 sec
Reputation Power: 4
Inserting data int MySQL

I have a MySQL datasource configured in Coldfusion and data can be added to the database.

I have parsed several websites for job data and stored the data into several lists. The data in the lists takes the form of:

Retail/Membership Assistant (title)
£10,000 - £11,500 pa (salary)
RSPB, Ribble Discovery Centre, Lancashire (location)

Full time Established (hours)
30 March 2005 (app date)
6 April 2005 (iterview date)

I try to add this data to my database:
<cfloop from="1" to="#listLen(idList)#" index="j">
<cfquery name="insJobRecord" datasource="project">
insert into job (ref, Title, Salary)
values
(<cfqueryparam value="#listGetAt(idList, j)#" cfsqltype="CF_SQL_VARCHAR">,
<cfqueryparam value="#listGetAt(TitleList, j)#" cfsqltype="CF_SQL_VARCHAR">,
<cfqueryparam value="#listGetAt(SalaryList, j)#" cfsqltype="CF_SQL_VARCHAR">)
</cfquery>
</cfloop>

However I get the following errror:
Invalid list index 2.
In function ListGetAt(list, index [, delimiters]), the value of index, 2, is not a valid as the first argument (this list has 1 elements). Valid indexes are in the range 1 through the number of elements in the list.

The error occurred in C:\CFusionMX\wwwroot\Project\1.cfm: line 97

95 : values
96 : (<cfqueryparam value="#listGetAt(idList, j)#" cfsqltype="CF_SQL_VARCHAR">,
97 : <cfqueryparam value="#listGetAt(TitleList, j)#" cfsqltype="CF_SQL_VARCHAR">,
98 : <cfqueryparam value="#listGetAt(SalaryList, j)#" cfsqltype="CF_SQL_FLOAT">)
99 :

All my datatypes in my database are the same as in my code. I can add the idlist values into the database but not the titlelist values. What am I doing wrong?

Thanks in advance

Reply With Quote
  #2  
Old March 29th, 2005, 06:56 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
The problem is that the titleList list does not have the same number of elements that the idList does, so on the second iteration of the loop you're getting an error because there is no second list element in the titleList.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old March 30th, 2005, 10:18 AM
samb1 samb1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 67 samb1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 42 m 42 sec
Reputation Power: 4
Thanks Kiteless, got another error that I dont really understant:
[Macromedia][SequeLink JDBC Driver][ODBC Socket][MySQL][ODBC 3.51 Driver][mysqld-4.0.21-nt]Column count doesn't match value count at row 1

The error occurred in C:\CFusionMX\wwwroot\Project\1.cfm: line 73

71 : (<cfqueryparam value="#Links[i]#" cfsqltype="CF_SQL_VARCHAR">,
72 : <cfqueryparam value="#thisJD#" cfsqltype="CF_SQL_LONGTEXT">
73 : <cfqueryparam value="#thisTitle#" cfsqltype="CF_SQL_VARCHAR">)


Again the datatype in the database and the code match, what does that mean?
Thanks

Reply With Quote
  #4  
Old March 31st, 2005, 05:31 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,328 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 6 h 56 m 2 sec
Reputation Power: 891
looks like a missing comma between lines 72 and 73
__________________
r937.com | rudy.ca

Reply With Quote
  #5  
Old April 1st, 2005, 06:23 AM
samb1 samb1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 67 samb1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 42 m 42 sec
Reputation Power: 4
thank you

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Inserting data int MySQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway