Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inconsistent 37000

Status
Not open for further replies.

simmerdown

Programmer
Jun 6, 2000
100
US
The app is a content management system for 50-some academic departments at a community college.

The edit-your-department's-content page displays a variable number of sets of three fields: FactSheetTitle, Curriculum, and CourseList. Additionally, users have the option to add or delete sets (referred to as "fact sheets") in each department. To keep things straight, I append to primary key of each fact sheet to the names of that fact sheet's fields. One example of the result:

form.FactSheetTitle47
form.Curriculum47
form.CourseList47

form.FactSheetTitle48
form.Curriculum48
form.CourseList48

form.FactSheetTitle54
form.Curriculum54
form.CourseList54

Since all of these are within the same <form></form>, I'm trying to loop through each set of form fields, performing an update query for each one.

Additionally complicating things, the Curriculum[FSID] field is displayed in the page within an Editize applet (pretty much a WYSIWYG &quot;textarea&quot;, very handy for a CMS. supplies html as the value of the form field. However, I've used this applet before without any trouble. It behaves as any other <input /> or <textarea> in how it's handled by the form as a form field.

The query &quot;factsheets&quot; (which got included earlier in the code, not shown here) gets a list of all fact sheets associated with the department you're saving, including their IDs (FSID in the code). Then I loop over that query:

<cfloop query=&quot;factsheets&quot;>
<!--- cfoutput the query code just to doublecheck --->
<cfoutput>
update tbl_FactSheets
set FactSheetTitle = '#form[&quot;FactSheetTitle&quot; & FSID]#',
Curriculum = '#form[&quot;Curriculum&quot; & FSID]#',
CourseList = '#form[&quot;CourseList&quot; & FSID]#'
where FSID = #FSID#
</cfoutput>

<!--- now perform the update --->

<cfquery name=&quot;savefs&quot; datasource=&quot;#deptdsn#&quot;>
update tbl_FactSheets
set FactSheetTitle = '#form[&quot;FactSheetTitle&quot; & FSID]#',
Curriculum = '#form[&quot;Curriculum&quot; & FSID]#',
CourseList = '#form[&quot;CourseList&quot; & FSID]#'

where FSID = #FSID#
</cfquery>
</cfloop>

I've tried several variations on this code using various combinations of Evaluate() and PreserveSingleQuotes() after appending the #FSID# to the field name, and I receive the same error that I'm currently getting.

I've uploaded an example of the error page to
When you're looking at it, keep in mind that the first half of the page is the <cfoutput>ed sql so you can see what is being written for the query. Then follows the error message.

You'll notice:
a) the <cfoutput>ed sql looks just fine. No apparent syntax errors, single quotes in the right place.
b) the ColdFusion error message shows the Curriculum field getting cut off only 200-some characters into the field.

The oddest thing is that I only get the error with certain departments in the system. Others with the same types of HTML being submitted (no crazy special characters or anything) work just fine.

Is there something subtle that I'm missing? I've been banging my head on my desk for a week now.
 
OK, so that was way too long. All I really need answered ...

is

<cfquery name=&quot;savefs&quot; datasource=&quot;#deptdsn#&quot;>
update tbl_FactSheets
set FactSheetTitle = '#form[&quot;FactSheetTitle&quot; & FSID]#',
Curriculum = '#form[&quot;Curriculum&quot; & FSID]#',
CourseList = '#form[&quot;CourseList&quot; & FSID]#'
where FSID = #FSID#
</cfquery>

correct syntax? Do I need to incorporate PreserveSingleQuotes()?
 
Arrgh. Yep, 'twas the silly single quotes.

Since the Curriculum field was the one giving me trouble, this did the trick:

<cfset Cur2= #form[&quot;Curriculum&quot; & FSID]#>
<cfset Cur3 = PreserveSingleQuotes(Cur2)>



I had tried making it one efficient statement like
<cfset Cur3 = PreserveSingleQuotes(form[&quot;Curriculum&quot; & FSID])>
but CF begged to be excused ... proper syntax apparently doesn't allow the brackets in there.

The query became

<cfquery name=&quot;savefs&quot; datasource=&quot;#deptdsn#&quot;>
update tbl_FactSheets
set CourseList = '#form[&quot;CourseList&quot; & FSID]#',
FactSheetTitle = '#form[&quot;FactSheetTitle&quot; & FSID]#',
Curriculum = '#Cur3#'
where FSID = #FSID#
</cfquery>

and all's well.
 
If it's still sticking in your craw... you might try:
Code:
<cfset Cur3 = PreserveSingleQuotes(&quot;#form[&quot;Curriculum&quot; & FSID]#&quot;)>
or
Code:
<cfset Cur3 = PreserveSingleQuotes(form[&quot;Curriculum#FSID#&quot;])>

one of which should work.

Though, if it's working, hell leave it alone.


-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top