Archive for the ‘Web Design’ Category

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.

[quickcode]

My content was coming out of the db here

[/quickcode]

What the code actually came out to be before we changed the field type.
[quickcode]

My content out of the db here

[/quickcode]

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]

Been A While – .Net Coldfusion and More

Tuesday, June 30th, 2009

.Net Code Snippet

.Net Code Snippet

Obviously, it has been a while since I have posted on my blog. Quite simply after starting my full time employment contract I have not had time. Why? I am working long hours doing many new things – such as programming in Coldfusion and .Net.

I took on a position of web developer and have now setup 2 Linux servers, coded a C# .Net app from the ground up and am looking at major site updates using Coldfusion. While entertaining, fun and challenging, it has meant a bit longer days at work than I had anticipated – however I am NOT complaining in the least amount. I have a full time job and am paying bills and getting caught up on things. That’s always good!

The past week and a half has brought more changes – I was told we are going to look at revamping the entire site and work and will be doing it in VB.Net, so more learning, which is one of the things I love most about IT and web development – the constant learning, expanding and maintenance of knowledge. With that, we are looking at making it easier to get content out, expanding on and integrating more with social media and getting an infrastructure in place that will allow forward motion, expansion and easier maintenance. This also means a more enhanced visitor and site user experience, which is always something that is highly important.

The other thing of note, is that I will try my best as I go through Coldfusion and .Net programming to get some tutorials, how-to’s and other related posts up on those subjects. I will be learning quite rapidly and am sure to have some struggles to fight through, and those are the items I would like to post about.

Three Simple Yet Effective PHP Tips and Tricks

Thursday, April 16th, 2009

Working on some freelance projects and personal projects recently, I found myself needing to do some simple things in PHP that actually had some great value in the end. I share these now in hopes that they will help someone else.

  1. Adjusting Case Sensitivity – You can use the following code to take any string and perform an initial caps on it. The outer function ucfirst performs the first letter capitalization, while the strtolower will automatically convert the entire string to lower case first. This allow any string with mixed case to be converted to initial caps on the first word.

  2. $myString = "HellO TheRE";
    echo ucfirst(strtolower($value));
    ?>

  3. More Case Sensitivity – instead of using just ucfirst, why not take a look at ucwords. This nifty little built-in PHP function will take and perform an initial cap on every word of a given string. Again, we would probably want to run the string through strtolower to ensure only the initial caps was performed. This may cause issues, however, if you are converting strings that contain acronyms or other words that are generally in all caps.

  4. $myString = "cool PHP";
    echo ucfirst($myString);
    ?>

    The output will be: Cool PHP

    However using it this way, you can see how it would change the output:

    $myString = "cool PHP";
    echo ucfirst(strtolower($myString));
    ?>

    The out of that last one will become Cool Php.

  5. File Uploads – When you allow file uploads, say for web site owners to upload images, it is best to check to see if the file exists first and if so remove the old version first. In this short example a filename is being dynamically built, but that is another discussion in another post.

    First, we build our file name – the second thing we do, since we are renaming and files to a standard naming convention is to check to see if the file exists. In this case we used a unique ID, an underscore and the image file name being passed into this function. You can use what ever you need to name your files. Second, the if statement checks for the existence of the file, and if true it deletes it using the PHP unlink function, then copies the new file over and finally reports any errors. If the file does not exist, the function simply moves to the else block and copies the new file.


  6. $fileName = “images/”.$id.”_”.$image;
    if(file_exists($fileName))
    {
    unlink($fileName);
    $copied = move_uploaded_file($_FILES['form_element_name]['tmp_name'], $fileName);
    if(!copied)
    {
    echo “upload failed for image “.$fileName.” or you didn’t upload that file
    “;
    }
    }
    else
    {
    $copied = move_uploaded_file($_FILES['form_element_name']['tmp_name'], $fileName);
    if(!copied)
    {
    echo “upload failed for image “.$fileName.” or you didn’t upload that file
    “;
    }
    }

New Theme Launched

Saturday, April 11th, 2009

Just put up a new theme on the blog. It’s my first customization attempt at a WordPress theme. Let me know what you think! I tried to keep it clean and simple, much better readability I think than the old black background with white text theme I had.

I do still have some items to change and tweak up, but that’s okay. I had to publish it at this point, or else it probably never would get done – at least only having a few tweaks left will motivate me to get them done since it is now live.


View in: Mobile | Standard