Skip to main content
nikos101
Inspiring
September 2, 2008
Answered

I am getting a horrible error: 'Unable to invoke CFC

  • September 2, 2008
  • 5 replies
  • 923 views
I am getting a horrible error when I try and call a cfc.

faultCode:Server.Processing faultString:'Unable to invoke CFC - Context validation error for the cffunction tag.' faultDetail:'The start tag must have a matching end tag. An explicit end tag can be provided by adding &lt;/cffunction&gt;. If the body of the tag is empty, you can use the shortcut &lt;cffunction .../&gt;.<p>The CFML compiler was processing:<ul><li>The body of a cfquery tag beginning on line 157, column 18.</ul>'


the cfc function in question is as follows:

<cffunction name="editUser" access="remote" returntype="boolean">
<cfargument name="firstName" required="true" type="string">
<cfargument name="surname" required="true" type="string">
<cfargument name="userName" required="true" type="string">
<cfargument name="password" required="true" type="string">
<cfargument name="staffID" required="true" type="numeric">
<cfargument name="area" required="true" type="string">
<cfargument name="position" required="true" type="string">





<cfquery name="q" datasource="#datasource#"> //(line 157)
update staff_charts_staff set
firstName = <cfqueryparam value="#arguments.firstname#" cfsqltype="cf_sql_varchar">,
surname = <cfqueryparam value="#arguments.surname#" cfsqltype="cf_sql_varchar">,
username = <cfargument name="#arguments.userName" required="true" type="string">,
password = <cfargument name="#arguments.password" required="true" type="string">,
staffID = <cfqueryparam value="#arguments.staffID#" cfsqltype="cf_sql_varchar">,
area = <cfqueryparam value="#arguments.area#" cfsqltype="cf_sql_varchar">,
position = <cfqueryparam value="#arguments.position#" cfsqltype="cf_sql_varchar">

</cfquery>

<cfset flash.result=true>
<cfreturn flash.result>
</cffunction>


Any ideas? Could it be a character encoding issue?
    This topic has been closed for replies.
    Correct answer Kronin555
    Yes, those 2 lines are bad:
    username = <cfargument name="#arguments.userName" required="true" type="string">,
    password = <cfargument name="#arguments.password" required="true" type="string">,

    They're also missing trailing # signs.

    Do you intend that query to update every single item in that table? If not, you might want to add a "where" clause.

    5 replies

    nikos101
    nikos101Author
    Inspiring
    September 2, 2008
    Opps sorry my Bad, thanks very much.

    Do you intend that query to update every single item in that table? If not, you might want to add a "where" clause.

    thanks for spoting that to, that would have been very painful indeed

    Inspiring
    September 2, 2008
    look at your username and password fields: you are setting them to
    <cfargument> instead of <cfqueryparam>

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    nikos101
    nikos101Author
    Inspiring
    September 2, 2008
    I've isolated the problem down to these lines of code:

    <cfquery name="q" datasource="#datasource#">
    update staff_charts_staff set
    firstName = <cfqueryparam value="#arguments.firstname#" cfsqltype="cf_sql_varchar">,
    surname = <cfqueryparam value="#arguments.surname#" cfsqltype="cf_sql_varchar">,
    username = <cfargument name="#arguments.userName" required="true" type="string">,
    password = <cfargument name="#arguments.password" required="true" type="string">,
    staffID = <cfqueryparam value="#arguments.staffID#" cfsqltype="cf_sql_varchar">,
    area = <cfqueryparam value="#arguments.area#" cfsqltype="cf_sql_varchar">,
    position = <cfqueryparam value="#arguments.position#" cfsqltype="cf_sql_varchar">

    </cfquery>
    Kronin555Correct answer
    Participating Frequently
    September 2, 2008
    Yes, those 2 lines are bad:
    username = <cfargument name="#arguments.userName" required="true" type="string">,
    password = <cfargument name="#arguments.password" required="true" type="string">,

    They're also missing trailing # signs.

    Do you intend that query to update every single item in that table? If not, you might want to add a "where" clause.
    nikos101
    nikos101Author
    Inspiring
    September 2, 2008
    No but when I remove this function the cfc works :(
    Inspiring
    September 2, 2008
    Something is missing an end tag. Is that the only function in your cfc?