[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

What's wrong with this query?

Posted on 2006-05-01
8
Medium Priority
?
153 Views
Last Modified: 2013-12-24
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
Comment
Question by:brucecrabtree
7 Comments
 
LVL 7

Expert Comment

by:wytcom
ID: 16579774
I wonder if you have a ")" char in your variables.recipents values?
0
 
LVL 10

Expert Comment

by:rob_lorentz
ID: 16580019
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
 
LVL 10

Expert Comment

by:rob_lorentz
ID: 16580030
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:gardine
ID: 16580371
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
 
LVL 14

Expert Comment

by:Renante Entera
ID: 16582452
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
 

Author Comment

by:brucecrabtree
ID: 16582567
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
 

Accepted Solution

by:
GranMod earned 0 total points
ID: 16792125
PAQed with points refunded (500)

GranMod
Community Support Moderator
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
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…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Screencast - Getting to Know the Pipeline
Suggested Courses

829 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