What's wrong with this query?

Posted on 2006-05-01
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#)

I can't see why. EventID and NoticeDate are both integer values.
Question by:brucecrabtree
    LVL 7

    Expert Comment

    I wonder if you have a ")" char in your variables.recipents values?
    LVL 10

    Expert Comment

    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#)
    LVL 10

    Expert Comment

    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">
    LVL 1

    Expert Comment


    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)#)
    LVL 14

    Expert Comment

    by:Renante Entera
    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)
      <cfqueryparam cfsqltype="cf_sql_integer" value="#Form.EventID#">,
      <cfqueryparam cfsqltype="cf_sql_varchar" value="#variables.recipients#">,
      <cfqueryparam cfsqltype="cf_sql_date" value="#form.NoticeDate#">

    I hope that this helps you.  Just try it.

    eNTRANCE2002 :-)

    Author Comment

    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>

    They should do the same thing, shouldn't they?  
    NoticeDate is not actually a date field, it's an integer field.

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now