We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

cfqueryparam: Incorrect syntax near '@P3'.

JohnLucania
JohnLucania asked
on
Medium Priority
2,310 Views
Last Modified: 2013-12-24
What is wrong with this?

<cfquery name="ClientNewInsert" datasource="VanProgram">  
Insert into Clients (ClientID,
     Title,  
     FirstName,  
     LastName,  
     MI,  
     Address,  
     Apt,  
     City,  
     State,  
     Zip,  
     Phone,  
     DOB,
     Lift,  
     Limits,  
     Comments,
     Directions,
     EmerContact,  
     EmerPhone,
     EmerPhone1)
values
(#TheNextClientID#,
     '#form.Title#',  
     '#form.FirstName#',  
     '#form.LastName#',  
     '#form.MI#',  
     '#form.Address#',  
     '#form.Apt#',  
     '#form.City#',  
     'OH',  
     '#form.Zip#',  
     <cfqueryparam value="#REReplace(form.Phone,'[^0-9]','','all')#" cfsqltype="CF_SQL_VARCHAR" />,
     '#form.DOB#',
     '#form.Lift#',  
     '#form.Limits#',  
     '#form.Comments#',
     '#form.Directions#',
     '#form.EmerContact#',  
     <cfqueryparam value="#REReplace(form.EmerPhone,'[^0-9]','','all')#" cfsqltype="CF_SQL_VARCHAR" />,
     <cfqueryparam value="#REReplace(form.EmerPhone1,'[^0-9]','','all')#" cfsqltype="CF_SQL_VARCHAR" />
</cfquery>


Error Executing Database Query.  
[Macromedia][SQLServer JDBC Driver][SQLServer]Line 39: Incorrect syntax near '@P3'.  
 
The error occurred in D:\Inetpub\wwwroot\VanProgram\NewClientInsert.cfm: line 54
 
52 :      '#form.EmerContact#',  
53 :      <cfqueryparam value="#REReplace(form.EmerPhone,'[^0-9]','','all')#" cfsqltype="CF_SQL_VARCHAR" />,
54 :      <cfqueryparam value="#REReplace(form.EmerPhone1,'[^0-9]','','all')#" cfsqltype="CF_SQL_VARCHAR" />
55 : </cfquery>
56 :  

--------------------------------------------------------------------------------
 
SQL    Insert into Clients (ClientID, Title, FirstName, LastName, MI, Address, Apt, City, State, Zip, Phone, DOB, Lift, Limits, Comments, Directions, EmerContact, EmerPhone, EmerPhone1) values (3915, 'DR', 'Test1', 'Test1', 'T', '1234 Test way', '', 'BEREA', 'OH', '41032', (param 1) , '01/01/1950', 'Yes', 'BRING WHEELCHAIR WITH', 'Test', 'test', 'Father', (param 2) , (param 3)  
Comment
Watch Question

Commented:
You need a closing )

     '#form.EmerContact#',  
     <cfqueryparam value="#REReplace(form.EmerPhone,'[^0-9]','','all')#" cfsqltype="CF_SQL_VARCHAR" />,
     <cfqueryparam value="#REReplace(form.EmerPhone1,'[^0-9]','','all')#" cfsqltype="CF_SQL_VARCHAR" />  )

Notice the closing ) I added.

I would also note that you really should consider using <cfqueryparam> for ALL the form literals passed into the insert... just my opinion.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
yup :-)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.