Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

ColdFusion Insert Query Inserts the Record Twice

Avatar of ostashenp
ostashenp asked on
Web DevelopmentWeb Development SoftwareWeb Applications
12 Comments1 Solution493 ViewsLast Modified:
I cant figure this out I think I have stared at it to long.  When I hit the insert Job Button can anyone tell me why it is inserting each record twice.  What is happening is this:

Text File:

Record1 ~
Record2 ~

Database:

Record1
Record2
Record1
Record2

Here is my Code:

<html>
<head>
<title>t</title>
<body>

<cfset file ="test.txt">
<cfset path = "D:\inetpub\test.txt">
<cfoutput>#Path#</cfoutput><br />

<cfif FileExists("#path#") is "Yes">

  File Is There: <br />
  <cfelse> no file
</cfif>  
<CFFILE ACTION="READ" FILE="#Path#" VARIABLE="datavar">


<CFSET crlf = "~">
<CFLOOP INDEX="orec" LIST="#datavar#" DELIMITERS="#crlf#">
<cfif len(trim(orec)) >

<cfquery name="getjobnumberInfo" datasource="test" dbtype="test">
      select max(jid) as NaxNum from Jobs
</cfquery>



<CFSCRIPT>
Jobnumber = ListGetAt(orec, 1,"|");
Jobtitle = ListGetAt(orec, 2,"|");
Location = ListGetAt(orec, 3,"|");
State = ListGetAt(orec, 4,"|");
Company = ListGetAt(orec, 5,"|");
Jobfield2 = ListGetAt(orec, 6,"|");
Website = ListGetAt(orec, 7,"|");
Joblisting = ListGetAt(orec, 8,"|");
</CFSCRIPT>
<cfparam name="County" default="Providence">
<cfparam name="Experience" default="">
<cfparam name="Referred" default="">
<cfparam name="Single" default="J">
<cfparam name="CBIA" default="N">
<cfparam name="exp_date" default="">
<cfparam name="eresumes" default="N">
<cfparam name="send_resumes" default="0">
<cfset dateentered = CreateODBCDate(dateadd('d',-1,now()))>
<cfset timeentered = CreateODBCtime(now())>
<cfset Moddate = CreateODBCDate(dateadd('d',-1,now()))>
<cfset Modtime = CreateODBCtime(now())>
<cfset exp_date = CreateODBCdate(dateadd("YYYY",5,now()))>
<cfset Temp = Replace(getjobnumberInfo.NaxNum, 'J', '', 'ONE') + 3000 >
<cfset jobnumber = "J#Temp#" >
<cfset login = "login">
<cfset pw = "ocjobs">
<cfset topusa = 1>







<table align="center">

<form action="test_get_jobs.cfm" method="post" name="InsertJobs">




<CFQUERY DATASOURCE="test" dbtype="test">
 INSERT INTO JOBS
(Company,jobnumber,City,State,location,JobTitle,topurl,JobField2,County,login,pw,single,dateentered,timeentered,Moddate,Modtime,eResumes,send_resumes,exp_date,topusa)
VALUES
('#Company#','#jobnumber#','#location#','#state#','#location#','#JobTitle#','#website#','#jobfield2#','#County#','#login#','#pw#','#single#',#dateentered#,#timeentered#,#Moddate#,#Modtime#,'#eResumes#','#send_resumes#',#exp_date#,'1')
 </CFQUERY>

</cfif>
</CFLOOP>

<tr>
<td><input type="submit" value="InsertJobs">
</td>
</tr>
</form>
</table>

</body>
</head>
</html>


ASKER CERTIFIED SOLUTION
Avatar of mkishline
mkishline

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answers