• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 156
  • Last Modified:

What's wrong with this query?

I'm getting this error:

Error Executing Database Query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 2

From this:

<cfquery name="AddNotify" datasource="#request.datasource#">
insert into tbl_notify(EventID_FK, Recipients, NoticeDate)
values(#Form.EventID#, '#variables.recipients#', #form.NoticeDate#)
</cfquery>

I can't see why. EventID and NoticeDate are both integer values.
0
brucecrabtree
Asked:
brucecrabtree
1 Solution
 
wytcomCommented:
I wonder if you have a ")" char in your variables.recipents values?
0
 
rob_lorentzCommented:
i think you need spaces before your '(', try this.....

<cfquery name="AddNotify" datasource="#request.datasource#">
insert into tbl_notify (EventID_FK, Recipients, NoticeDate)
values (#Form.EventID#, '#variables.recipients#', #form.NoticeDate#)
</cfquery>
0
 
rob_lorentzCommented:
also, make sure there is a value in form.eventId and form.noticeDate

<cfparam name="form.eventId" default="0">
<cfparam name="form. noticeDate" default="0">
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
gardineCommented:
Hi,

Give this a try:

<cfquery name="AddNotify" datasource="#request.datasource#">
insert into tbl_notify(EventID_FK, Recipients, NoticeDate)
values(#Form.EventID#, '#variables.recipients#', #CreateODBCDate(form.NoticeDate)#)
</cfquery>
0
 
Renante EnteraSenior PHP DeveloperCommented:
Hi brucecrabtree!

Surround your NoticeDate value with single quote and make sure that it has the right date format.

Or just to be safe, try to use "<cfqueryparam>" tag.

This will be the code :
----------------------------------------------------------------------------------
<cfquery name="AddNotify" datasource="#request.datasource#">
insert into tbl_notify(EventID_FK, Recipients, NoticeDate)
values
(
  <cfqueryparam cfsqltype="cf_sql_integer" value="#Form.EventID#">,
  <cfqueryparam cfsqltype="cf_sql_varchar" value="#variables.recipients#">,
  <cfqueryparam cfsqltype="cf_sql_date" value="#form.NoticeDate#">
)
</cfquery>
----------------------------------------------------------------------------------

I hope that this helps you.  Just try it.


Goodluck!
eNTRANCE2002 :-)
0
 
brucecrabtreeAuthor Commented:
Thanks for the ideas. I got it to work, though I'm not sure why, by changing

<cfparam name="form.NoticeDate" default="1">

at the top of my page to

<cfif not isDefined("form.NoticeDate")>
<cfset form.noticedate = 1>
</cfif>

They should do the same thing, shouldn't they?  
NoticeDate is not actually a date field, it's an integer field.
0
 
GranModCommented:
PAQed with points refunded (500)

GranMod
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now