【发布时间】:2011-07-13 15:30:57
【问题描述】:
我有一个 CFC,负责处理招聘网站上的“联系我们”类型的表单。 cfc 旨在处理来自站点的几种不同形式;一个通用的“联系我们”表单和另一个“我对此工作感兴趣”表单。
当 CFC 获取数据,并且职位发布的 ID# 包含在参数中时,CFC 会进行快速查询并获取职位发布信息,将其包含在电子邮件中并向 HR 部门和用户发送包含职位发布信息以及用户联系信息的电子邮件。
如果未检测到 ID,CFC 只会向用户发送一封确认电子邮件并将联系信息发送给 HR 部门。
处理通用(非 ID)表单后一切正常。但是,当需要处理包含快速查询的表单时,我收到一个错误:
Communications link failure The last packet successfully received from the server was 61,380 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.
为什么填充我的页面的查询可以正常工作,但此 CFC 会在其中引发查询错误?
我们在共享主机环境中使用 MYSQL 运行 CF9。
CFC...
<cfif len(local.data.job_id)>
<cftry>
<cfquery name="qJobsforEmail" datasource="#application.datasource#" username="#application.username#" password="#application.password#">
SELECT * FROM #local.data.table# WHERE #local.data.table#.#local.data.column#= <cfqueryparam value="#local.data.job_id#" cfsqltype="cf_sql_numeric">
</cfquery>
<cfcatch type="any">
<cfmail to="my@email.com" from="server@host.com" subject="Error processing query" type="html">
<h3>There was an error processing the query</h3>
<p><cfoutput>#cfcatch.Detail#</cfoutput></p>
<p><cfoutput>#cfcatch.NativeErrorCode#</cfoutput></p>
<p><cfoutput>#cfcatch.SQLState#</cfoutput></p>
<p><cfoutput>#cfcatch.Sql#</cfoutput></p>
<p><cfoutput>#cfcatch.queryError#</cfoutput></p>
<p><cfoutput>#cfcatch.where#</cfoutput></p>
<p><cfoutput>#cfcatch.type#</cfoutput></p>
<cfdump var="#local#">
</cfmail>
<cfset local.response["error"] = 'true'>
<cfset local.response["message"] = 'Error message to the page goes here...'>
<cfreturn local.response>
<cfabort>
</cfcatch>
</cftry>
<cftry>
<cfmail to="#local.data.email#" bcc="hr@theclient.com" from="server@host.com" subject="Thank you for contacting us" type="html">
<h2>We’re glad you contacted us.</h2>
<p>Warm and fuzzy thank you message here</p>
<p>We received the following information on <cfoutput>#DateFormat(Now())#</cfoutput>, <cfoutput>#TimeFormat(Now())#</cfoutput>: </p>
<p>First Name: <cfoutput>#local.data.first_name#</cfoutput></p>
<p>Last Name: <cfoutput>#local.data.last_name#</cfoutput></p>
<cfif len(local.data.suffix)>
<p>Suffix: <cfoutput>#local.data.suffix#</cfoutput></p>
</cfif>
<p>Specialty: <cfoutput>#local.data.specialty#</cfoutput></p>
<p>Email Address: <cfoutput>#local.data.email#</cfoutput></p>
<p>Phone: <cfoutput>#local.data.phone#</cfoutput></p>
<p> Current City and State: <cfoutput>#local.data.city#</cfoutput></p>
<cfif len(local.data.comments)>
<p>Message: <cfoutput>#local.data.comments#</cfoutput></p>
</cfif>
<p style="border-top:thin dotted black;padding-top:20px;font-weight:bold;">This is the position you’re inquiring about:</p>
<p style="font-weight:bold;"><cfoutput>#qJobsforEmail.title#</cfoutput></p>
<p style="padding-bottom:20px;"><cfoutput>#qJobsforEmail.description#</cfoutput></p>
<p>Our Recruiter will review this information and get in touch with you as soon as possible. Please make sure your email or phone number listed above is correct.</p>
<p>Thanks again for contacting us. We look forward to speaking with you soon.</p>
</cfmail>
<cfcatch type="any">
<cfmail to="my@email.com" from="server@host.com" subject="Error processing email" type="html">
<h3>There was an error processing the email at</h3>
<cfdump var="#cfcatch.Detail#">
<cfdump var="#local#">
</cfmail>
<cfset local.response["error"] = 'true'>
<cfset local.response["message"] = 'message to return to the page...'>
<cfreturn local.response>
<cfabort>
</cfcatch>
</cftry>
<cfelse>
<!-- regular ol form process goes here -->
</cfif>
【问题讨论】:
标签: mysql coldfusion cfc