-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[EMAIL PROTECTED] wrote:

> I'm a complete newbie at Coldfusion, and have a pretty basic  question.
>  
> I'm trying to get an update page working, and it keeps returning the  error:
>      
> Error  Executing Database Query. 
> Syntax error in UPDATE  statement.     The error occurred in  
> C:\CFusionMX7\wwwroot\CFIDE\gettingstarted\tutorial\update2.cfm: line  65
> 63 :       NULL
> 64 :   </cfif>
> 65 :   WHERE ID=#FORM.hiddenField#
> 66 :   </cfquery>
> 67 : </cfif>

The root of that error was that your query didn't have a name. However,
there's other problems with it too.

If you're setting values to null in a table, it's much better to use
<cfqueryparam>. I've rewritten your code to use it. Also, if you want
to check if you're being posted data, use the REQUEST_METHOD CGI
variable. Rather than having two different parameters with the same
basic meaning (URL.recordID and FORM.hiddenField), just use the one
name (recordID). Just use 'recordID', and CF will resolve this to either
URL.recordID or FORM.recordID.

I've assumed that your values are all VARCHARs, though you should change
them to whatever they really should be. Check the <cfqueryparam> docs
for a list of them.

- ---- CUT HERE ----

<cfsilent>
<cfparam name="recordID" type="numeric" default="1">

<cfif CGI.REQUEST_METHOD eq "POST">
    <cfparam name="FORM.name"        type="string" default="">
    <cfparam name="FORM.surname"     type="string" default="">
    <cfparam name="FORM.sex"         type="string" default="">
    <cfparam name="FORM.height"      type="string" default="">
    <cfparam name="FORM.playing_age" type="string" default="">
    <cfparam name="FORM.DOB"         type="string" default="">
    <cfparam name="FORM.Hair"        type="string" default="">
    <cfparam name="FORM.Eye"         type="string" default="">
    <cfparam name="FORM.Image"       type="string" default="">
    <cfparam name="FORM.Training"    type="string" default="">

    <cfquery name="update" datasource="artists">
    UPDATE  Sheet1
    SET     Name        = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#FORM.name#"        null="#(FORM.name eq '')#">,
            Surname     = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#FORM.surname#"     null="#(FORM.surname eq '')#">,
            Sex         = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#FORM.sex#"         null="#(FORM.sex eq '')#">,
            Height      = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#FORM.height#"      null="#(FORM.height eq '')#">,
            Playing_age = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#FORM.playing_age#" null="#(FORM.playing_age eq '')#">,
            DOB         = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#FORM.DOB#"         null="#(FORM.DOB eq '')#">,
            Hair        = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#FORM.Hair#"        null="#(FORM.Hair eq '')#">,
            Eye         = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#FORM.Eye#"         null="#(FORM.Eye eq '')#">,
            Image       = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#FORM.Image#"       null="#(FORM.Image eq '')#">,
            Training    = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#FORM.Training#"    null="#(FORM.Training eq '')#">
    WHERE   ID          = <cfqueryparam cfsqltype="CF_SQL_INTEGER"
value="#FORM.hiddenField#">
    </cfquery>
</cfif>
<cfquery name="artist" datasource="artists">
SELECT  *
FROM    Sheet1
WHERE   ID = <cfqueryparam cfsqltype="CF_SQL_INTEGER"
value="#URL.recordID#">
</cfquery>
</cfsilent>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>

<html xml:lang="en" lang="en"><head>

    <title>Untitled Document</title>

</head><body>

<cfoutput query="artist">
<form action="#HTMLEditFormat(GetFileFromPath(GetTemplatePath()))#"
method="post">
<input type="hidden" name="recordID"    value="#recordID#">
<input type="text"   name="name"        value="#HTMLEditFormat(name)#">
<input type="text"   name="surname"     value="#HTMLEditFormat(surname)#" />
<input type="text"   name="sex"         value="#HTMLEditFormat(sex)#" />
<input type="text"   name="height"      value="#HTMLEditFormat(height)#" />
<input type="text"   name="playing_age"
value="#HTMLEditFormat(playing_age)#" />
<input type="text"   name="DOB"         value="#HTMLEditFormat(DOB)#" />
<input type="text"   name="Hair"        value="#HTMLEditFormat(hair)#" />
<input type="text"   name="eye"         value="#HTMLEditFormat(eye)#" />
<input type="text"   name="Image"       value="#HTMLEditFormat(image)#" />
<input type="text"   name="training"
value="#HTMLEditFormat(training)#" />
<input type="submit"                    value="Submit" />
</form>
</cfoutput>

</body></html>

- ---- CUT HERE ----

K.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCpypfmSWF0pzlQ04RAoUfAJ43RoZsHU8WB9B+eki5kbzvBtCdTACeIjBh
cfgj875TrqKoNOfyJ72fDOs=
=Ypde
-----END PGP SIGNATURE-----

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209001
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to