Are you sure your data in the database is not HTML Encoded?

http://www.w3schools.com/tags/ref_symbols.asp

if it is, than the FindNoCase() function will not find "<body>" since it would 
actually be "&lt;body&gt;" inside the database. This would also explain why you 
see the code in your browser since your browser would be decoding it for 
display.

You could try either a CFDump of the variable from the database or you could 
wrap it inside textarea tag (I think this will prevent the browser from 
decoding it) so you can see the actual data.

Hope this helps.


-----Original Message-----
From: Monique Boea [mailto:[email protected]] 
Sent: Thursday, July 21, 2011 4:03 PM
To: cf-newbie
Subject: Re: Displaying HTML from a database


I did the same and it worked when I used to actual output like you did below
but when I add the variable, I get the same error message:

Here is the code:

  <cfsavecontent variable="content">
  <cfoutput>#enrollmentInstructions.strText#</cfoutput>
  </cfsavecontent>


 <cfset startBody = FindNoCase("<body>", enrollmentInstructions.strText,1)>
 <cfset endBody = FindNoCase("</body>", enrollmentInstructions.strText,
startBody)>
 <cfset newContent = mid(enrollmentInstructions.strText, startBody +5,
endBody - startBody -5)>

<cfoutput>#newContent#</cfoutput>


Here is the error:

The 3 parameter of the Mid function, which is now -5, must be a non-negative
integer

On Thu, Jul 21, 2011 at 3:50 PM, Mike Chytracek <[email protected]> wrote:

>
> Actually I can get that data to display either way.  Here's my EXACT script
> I'm using to test what you have.  Cut and paste this into a file and run
> it...  It COULD be the doctype you are using.
>
>
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml";>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <title>Untitled Document</title>
> </head>
>
> <body>
>
> <cfsavecontent variable="content">
> <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta
> http-equiv="Content-Type" content="text/html; charset=windows-1252">
> <title>CITI Course Enrollment questions</title> </head> <body> <div
> align="center"> <table border="0" width="90%" id="table1" cellpadding="2">
> <tr> <td> <p> <img border="0" src="
> https://www.citiprogram.org/citidocuments/001_RCR/RCRbanner3.jpg";> </p>
> <h1>CITI Course Enrollment questions</h1> <p>You will be provided a series
> of questions. Your responses will determine the curriculum for the courses
> you are going to take. Please read the questions carefully. Please read the
> responses carefully to make the best choice. </td> </tr> <tr> <td> This
> Institution  provides a course for Human Subjects Protection and Laboratory
> Animal Welfare.<h2><b> Human Subjects Protection Course:</b></h2> <ul>
> <li>If you have NOT completed a CITI course at this Institution previously,
> you are required to complete the BASIC course at this time. </li> <li>If
> you
> have completed the CITI Basic course since 5-1-2004, the software is
> programmed to show you the CITI Re-fresher course now. </li> <li>You may be
> able to fulfill your refresher obligation with the CITI Good Clinical
> Practice Course.  Please consult your IRB office. </li> </ul> <p>For more
> detailed information review the instruction's page of your Institution.
> This page is available as a link at the top of this page</p>
> <h2><b>Laboratory Animal Welfare Course</b></h2> <p>If you are planning to
> use lab animals in your work:</p> <ul> <li>Choose the appropriate courses
> according to your role in research and the species you use.</li> <li>Choose
> all that apply.</li> <li>If you have questions regarding your training
> requirements, you should contact your IACUC Office.</li> </ul> <p><h2
> align="left"><b>CITI Curriculum Selection</b></h2> <p>You may enroll in
> multiple courses.  You can take the courses sequentially or together. You
> should use multiple login sessions.  The vaialble courses in the CITI
> program are:</p> <ul> <li>The Human Subjects Courses</li> <li>The Lab
> Animal
> Welfare Courses </li> <li>Good Clinical Practice (GCP)</li> <li>Health
> Information Privacy and Security (HIPS)</li> <li>Responsible Conduct of
> Research (RCR)</li> </ul> </td> </tr> </table> </div> </body>
>
> </cfsavecontent>
>
>
>  <cfset startBody = FindNoCase("<body>", content,1)>
>  <cfset endBody = FindNoCase("</body>", content, startBody)>
>  <cfset newContent = mid(content, startBody +5, endBody-startBody-5)>
>
> <cfoutput>#newContent#</cfoutput>
>
> </body>
> </html>
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:5383
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm

Reply via email to