SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict AshleyH's Avatar
    Join Date
    Mar 2005
    Posts
    260
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    whats wrong with this??

    I have this:

    Code:
    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
    <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1">
    
    <CFQUERY NAME="getCustomer" datasource="#request.dsn#"> 
     *SELECT * FROM tbl_contacts WHERE con_Customer = '#form.con_Customer#' 
     *</CFQUERY> 
    
    <CFIF getCustomer.RecordCount IS NOT 0> 
     <CFLOCATION URL="addcontact.cfm?customer=exists">
     </CFIF>
    I get this error with SQL Server

    Line 1: Incorrect syntax near ' '.
    *SELECT * FROM tbl_contacts WHERE con_Customer = '#form.con_Customer#'

    any ideas where it's wrong? Works fine for MySQL but not for SQL.

  2. #2
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It might have been a typo, but should the ColdFusion code look more like:

    Code:
    <CFQUERY NAME="getCustomer" datasource="#request.dsn#"> 
    SELECT * FROM tbl_contacts WHERE con_Customer = '#form.con_Customer#' 
    </CFQUERY>
    Also, what field type is con_Customer? It's good practise to surround any ColdFusion variables in a WHERE clause in a cfqueryparam tag. E.g.
    Code:
    <CFQUERY NAME="getCustomer" datasource="#request.dsn#"> 
    SELECT * FROM tbl_contacts WHERE con_Customer = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.con_Customer#" />
    </CFQUERY>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •