gpt4 book ai didi

Coldfusion 组件 :- The argument passed to the function is not of type numeric

转载 作者:行者123 更新时间:2023-12-03 11:23:24 26 4
gpt4 key购买 nike

我有一个简单的表单

表格.cfm:-

 <cfset Registr = createObject("component", "forms.Registr") /> 
<cfset setFoo = createObject('component','forms.Registr).putNUsr(username,password,rating) />

<form name="regFrm" action="#cgi.script_name#" method="post" onsubmit="submitform();" >
<tr><td>Username:</td>

<td><input type="text" name=" Username" value="#form. Username#" ></td></tr>


<tr><td>Password:</td>
<td><input class="" type="password" name="password" value="#form.password#" ></td></tr>

<tr><td>Rate:</td>

<select name="rating" >
<option value="" ></option>
<cfloop query="qGetReting">
<option value="#rating_id#" <cfif form. rating eq prof_id>selected</cfif> >#rating#</option>
</cfloop>
</select>
</td>
</tr>
</form>

现在“forms”文件夹中有一个名为Registr.cfc 的cfc,它有一个名为“putNUsr”的插入函数,“Registr.cfc”的代码如下。

<cfcomponent>
<cffunction name="putNUsr" returntype="void" displayname="" output="no">
<cfargument name="password" type="string" required="true">
<cfargument name="rating" type="numeric" required="true">
<cfargument name="username" type="string" required="true">
<cfquery datasource="#application.xyz#" name="q_putNUsr">
insert into
users (username
, password
, rating)

values(

<cfqueryparam value="#arguments. username#" cfsqltype="CF_SQL_VARCHAR" />,
<cfqueryparam value="#arguments.password#" cfsqltype="CF_SQL_VARCHAR" />,
<cfqueryparam value="#arguments.rating#" cfsqltype="CF_SQL_INTEGER" )

</cfquery>
</cffunction>
</cfcomponent>

如果我不使用表单字段“评级”,我可以用数据填充数据库是数字。否则我会收到如下错误:-

The RATING argument passed to the putNUsr function is not of type numeric. 
If the component name is specified as a type of this argument, it is possible that either a definition file for the component cannot be found or is not accessible.

亲切的帮助-S瓦利

最佳答案

您已将函数中的参数顺序定义为密码、评级、用户名,但您按用户名、密码、评级的顺序传递参数。

您确实可以选择使用 ColdFusion 将参数作为命名参数传递,例如 putNUsr(username = 'me', password = 'letmein', rating = 5)。当你这样做时,你可以按任何顺序传递它们

关于Coldfusion 组件 :- The argument passed to the function is not of type numeric,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2718934/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com