Posts Tagged ‘html’

ColdFusion and MSSQL NText Fields

Tuesday, August 4th, 2009
Computer science
Image via Wikipedia

Late last week I was working on some new changes to PBR’s web site (my employer) and ran into a nasty snag of an issue. I was pulling data out of a table, and for an exceptionally strange reason, seemingly random HTML kept appearing in the source code. Needless to say, this HTML was breaking the layout I had been working towards and boggled not only my mind, but our SVP of IT’s mind as well.

In the end, we ended up changing the field type as it was held in the Microsoft SQL database. The field was originally set to be an ntext field, and we changed it to a varchar field, as it really had no purpose being an ntext field in the first place, but that’s another story. After we made the change, we did lose some data on the resulting trimming of the data field, however the parts that were trimmed were already migrated to another field, so big loss.

As soon as we changed this, the HTML injections ceased. What happened? I have put some sample code below to illustrate it.

What the code should have came out to be.

Quick Code


<div id="myDiv">
     <p class="indentClass">
          My content was coming out of the db here
     </p>
</div>

What the code actually came out to be before we changed the field type.
Quick Code


<div id="myDiv">
     <p class="indentClass">
          </p>
      <p>My content out of the db here</p>
      <p></p>
</div>

You can see that my opening paragraph tag was automatically closed, a new one started and closed after the database content was published, and an empty paragraph added at the end.

Now it is possible that the site, with the many thousands of pages and hundreds of thousands of lines of code specified this in a CFC or CFTAG file – in other words it was tied to the field name/type to force the HTML output, but I could not find it anywhere.

Any thoughts or experience you may have on this? Share them in the comments.

Reblog this post [with Zemanta]

Why clean code and markup matters on a web site

Tuesday, July 14th, 2009
A graphical despiction of a very simple html d...
Image via Wikipedia

I work for the Professional Bull Riders, Inc. in the capacity of Web Developer (Visit the PBR Online. Recently we have been looking at making changes to the site, adding more content pages, restructuring the layout on some of the internal pages to be more modern looking and reviewing search engine optimization and marketing.

All of this is necessary for growth, sustained visitors, enhancements and general creating forward motion on any given web site, especially for one that is in the top tier of sports entertainment. The issue happens, as it has happened at countless other enterprises, the code base is getting older, has been touched by many programmers over the years and is nearing point of needing to be completely rewrote to be modernized. That happens. No question.

The discussion here is, does clean, well commented code help sustainability in an application, including a web application? Short answer is yes. Does valid HTML markup do the same? Again, the short answer is yes. If the code base that exists is written using proper and valid HTML/XHTML markup, and is commented properly or document properly to give other developers a decent idea of the logic behind any given subset of functions, routines and other logic to understand what was being done and why. It also helps for the same developer when he/she needs to go back and make changes on code that may have been written months, even years prior.

As we move forward at my place of employment, we are looking at various platforms, ideas and methodologies to create a platform that is extensible, pliable and can be built upon in the future. This platform, as it will become, will be something that can be built upon to create the best possible presence, as any enterprise should have a goal of accomplishing.

So does clean code and markup matter? Yes it does, and if your enterprise, business, or site is lacking in that area, shouldn’t it be about time to correct that situation?

Reblog this post [with Zemanta]