SiteCrafting Blah Blah Blog

Mar. 31, 2008 at 11:40am

Got API?

An API reference does a method's body good...

gotAPI.com is one of the most useful online resources I've come across, primarily because it places resources spread all over the internet into one simple site. I've been using this for quite some time, and have for the most part I have taken its usefulness for granted. Then it occurred to me that I might not be the only one that could find this tool useful (I know, it was a big 'DUH!' moment). So now I will share this gem with others...

Read more

Comments (1) | Posted in ASP.NET 2.0, CSS, From the Workbench, Javascript, MS SQL Server, MySQL, PHP, Review, Software Engineering, XHTML by Nick Williams


Jan. 29, 2008 at 3:15pm

PHP Patterns, Part III

The TO Pattern

The Template Object (or TO) is a design pattern of my own that I developed to fill the role of the View layer in the MVC model. As you have probably figured out, the purpose of the TO is to handle everything related to the user interface. The idea here is to separate the interface as much as possible from the rest of the application, so that we could do a complete rewrite of an application without ever touching (or accidentally "breaking") the view portion. Read more

Comments (0) | Posted in Coding Techniques, From the Workbench, PHP, Software Engineering by Nick Williams


Nov. 30, 2007 at 1:05pm

Why is AOL denying email?

Try adding a parameter to the mail() function

Email debugging is often frustrating and time consuming. There could be numerous reasons why the email you attempted to send out through your code fails: routing issues, firewalls, company servers blacklisting or blocking incoming emails, spam filters, bad DNS records, and email header requirements. The last one can definetely lead to infinite frustration, as I have experienced in the past, and was recently the cause of why AOL was denying emails generated by the php mail() function.

Read more

Comments (1) | Posted in From the Workbench, PHP by Ken Foubert


Nov. 14, 2007 at 3:48pm

PHP Patterns, Part II

The DAO and VO Patterns

In this installment, we will be looking at two patterns that have been 'borrrowed' from Java. If you've had any development experience with J2EE, you are probably well aware of how handy Data Access Objects and Value Objects can be. If you haven't, don't fret! This article was written especially for you!

If you've never heard these terms before, you may be wondering why I have chosen to group them together within one article. The simple explanation is ... well you'll see. For now just accept that they go hand-in-hand, much like salt and pepper or peanut butter and jelly or <insert clever combination here>.

Excited? Let's dig deeper...

Read more

Comments (4) | Posted in Coding Techniques, From the Workbench, MySQL, PHP, Software Engineering by Nick Williams


Oct. 29, 2007 at 10:48am

Powered by Coffee

We all know that design and development firms are really run on caffeine. Coffee, energy drinks, tea, and even energy beers now. I usually can be found with 2-3 coffee cups on my desk throughout the week but I will never forget about one developer who I worked with. Each day he would purchase 3-4 drip coffees from Starbucks and then would stack the cups creating a wall about 5 layers high creating his own cubical wall.  It was all fine until one day when a few of them turned sour and his office buddy/management put an end to it.

What do you prefer to drink while working? I'm usually a fan of mochas or red bull. Have any ridiculous stories about coworkers caffeine habits?

Comments (9) | Posted in From the Workbench by Michael Pierce


Sep. 12, 2007 at 4:52pm

AJAX & IE Caching Issues

I've been working on a project that involves using the jQuery javascript library and the Ajax methods. I've been happily using the Ajax jQuery.get() method to handle simple calls, such as a link that allows a user to view a list of words based on their selection, getting the contents of a tab when the user selects a tab, and finally getting the current weather after the person enters a new zip code, which is then saved to the database.

For the last operation, I got the JavaScript working great on Firefox and I thought it was working in Internet Explorer. However, after some testing, I noticed that the same weather data was being returned, even after a new zip code on the opposite coast was selected. Mmmm, I was rather baffled, especially since I've been using this jQuery.get() on the other functions, and encountered no problems like this.

Read more

Comments (0) | Posted in From the Workbench, Javascript by Ken Foubert


Aug. 9, 2007 at 4:14pm

Getting the Client’s IP Address

There are a number of reasons why you may want to capture a web user's IP address. You may want to only allow certain IP addresses to view your website, to allow only one vote per IP address, track unique clicks on links and buttons, a location of web users on Google Maps using MASHUP, and whatever else you can think of.

Below are a couple of examples to get the client's IP address in PHP and ASP.net, along with a couple of things to watch for.

Read more

Comments (0) | Posted in ASP.NET 2.0, Coding Techniques, From the Workbench, PHP by Ken Foubert


Jul. 27, 2007 at 2:56pm

PHP Code in The Background Part 2

Passing Arguments To Command Line

The blog entry How To Run PHP Code In The Background discussed how to run a php file through the command line using php's exec() command.  Recently, I needed to pass a querystring to the php file, but this is not possible through the command line. If you try to pass a querystring, the exec() command will fail.

Fortunately, after some googling, I came across a forum post that mentioned how the global array $_SERVER["argv"] can be used to get arguments being passed through php. I then followed the link on that page to Chapter 43. Using PHP from the command line on  the php.net website. Under the user contributed notes, I found a nice little function for getting the arguments and placing them into an array, similar to $_GET, $_POST, and $_REQUEST.

Read more

Comments (0) | Posted in From the Workbench, PHP by Ken Foubert


Jul. 23, 2007 at 5:29pm

ASP.net 2.0 Gridview vs. Custom Coding

A balance of needs and time

I recently decided to try the Gridview control in asp.net 2.0. I read some documentation and decided that it would be very easy to implement. I started by following a step-by-step tutorial on creating a table using the Gridview control, which uses the SqlDataSource control. This step-by-step tutorial included details on how to add paging, column sorting, updating a record, and deleting a record. The tutorial can be found here.

I was actually excited when I got this to work and how easy it was to do. It would only take a few minutes to create a simple, paged, sortable table where a user can delete and update records right on the page. Please note that simple is the operative word here.
Read more

Comments (2) | Posted in ASP.NET 2.0, Coding Techniques, From the Workbench by Ken Foubert


Jun. 4, 2007 at 11:31am

ASP.NET 2.0 Tips - Shared Functions

Visual Basic for ASP.NET 2.0

When developing a recent project for ASP.NET, there was a need to migrate a large number of generic functions that were created in PHP into the .net web project. For .net 1.0, you were able to add a code page that could be used for creating a bunch of functions. However, in .net 2.0, you still had the ability to add a code page, but it had to be a class. This meant placing all of our migrated functions as methods inside a class. To use a generic function, such as generateNewPassword(), you would have to first create a new object for the class and then call the method. Read more

Comments (0) | Posted in ASP.NET 2.0, Coding Techniques, From the Workbench by Ken Foubert


Apr. 18, 2007 at 1:08pm

PHP PEAR and include_path

When attempting to use the SMTP library from PEAR for a project, I was having problems with including the file. I kept getting a file stream error for this code:

require 'Net/SMTP.php';

I figured the problem had to be related to the include_path setting in the configuration file.

Read more

Comments (0) | Posted in Coding Techniques, From the Workbench, PHP by Ken Foubert


Apr. 13, 2007 at 2:19pm

How To Run PHP Code In The Background

PHP Asynchronous Programming

If you have php code that would take longer than 5 minutes to run, what would you do?

You could update the configuration file for apache, or whatever web server you're running, to increase the amount of time a script page is allowed to run  and then use php's ini_set("max_execution_time", seconds) to increase the amount of time php will allow a script to run.

Or you could use a session variable to mark the last position of the script and then use meta-refresh to start the script at the last position.

Or you could try an asynchronous call by using php's exec command.
Read more

Comments (9) | Posted in From the Workbench, Odds 'n Ends, PHP by Ken Foubert


Apr. 9, 2007 at 4:36pm

Printing without the Dialog

One day, one of our clients came to us with a very unusual request - they wanted to be able to print something directly from the browser, but without displaying the usual print dialog box. I don't have much time in the webdev business, but I've never heard of this kind of request, and neither had anyone else in the office.
Read more

Comments (0) | Posted in From the Workbench, Javascript, Odds 'n Ends, PHP by Dave Poole


Apr. 2, 2007 at 2:36pm

PHP cURL and SSL Connection Timeout

I've been working on a web site that uses cURL for request/response transactions and I was encountering a number of problems with empty responses from the server. This caused some frustrations, since these empty responses caused entire sections of a web page to be empty, especially on searches. Well, I couldn't have that, since people using the website would be confused on why a search for an item only worked occasionally. Trust in the web application would drop dramatically. Read more

Comments (2) | Posted in From the Workbench, PHP by Ken Foubert


Feb. 20, 2007 at 2:53pm

Optimizing GROUP BY with Multiple LEFT JOINS

Creative use of temporary tables

At SiteCrafting, I enjoy working with a large number of different projects, each with their own requirements, technology, and problems to be solved, unfortunately, I sometimes forget about past solutions, until after I have finished writing a piece of code. Such is the case with a query that was eating up some serious processing time.

The problem was with a GROUP BY query with LEFT JOINs to several other tables and summing up totals from those joined tables. This query was taking about 4 minutes 45 seconds to run, and worse yet, it was affecting searches which had nothing to do with that query, and probably also eating up precious memory and cpu resources.

Read more

Comments (0) | Posted in From the Workbench, MySQL, PHP by Ken Foubert


Jan. 19, 2007 at 4:52pm

Emulating Form POST in PHP

There's small choice in rotten apples.

Recently, I had a need to POST a form, using PHP script, to a remote url.  As I started to research a solution, I soon realized there were very few limited options.

Read more

Comments (4) | Posted in Coding Techniques, From the Workbench, PHP by Ken Foubert


Nov. 3, 2006 at 10:51am

How To Full-Text Search

Inspired by Joe's MySQL Cross Table Content Search


Here's a quick how-to on implementing Full-Text Searching using Microsoft SQL Server 2005. Originally, I planned on just using LIKE statements in the WHERE clause of an sql query, however, this would not be possible since, as I posted earlier in MS SQL Server 2005 text and ntext, that string functions do not work on text and ntext data types.

That's when I remembered Joe's blog entry about Cross Table Content Search, which he also mentioned in the office a couple of times before his entry. After that, I've been wanting to implement the Cross Table Content Search, and did not get the opportunity until developing the search page for the Pierce County Library.
Read more

Comments (0) | Posted in ASP.NET 2.0, From the Workbench, MS SQL Server by Ken Foubert


Oct. 30, 2006 at 1:04pm

Why We Build Our Stuff from Scratch

It's never the same twice.

I had an interesting conversation with a potential client last Friday and it prompted me to think or at least explain our development rational.  He was looking to hire SiteCrafting to assemble a robust application for his client consisting of a design he came up with as well as some "open-source" technologies, and a few custom scripts generated by us. Long and the short of it...it seemed a disaster in the making.

I mentioned to him that SiteCrafting builds our Web applications from the ground up, for each customer as an individual. We do not offer one-size fits all solutions, because just like anything one-size fits all it never fits anyone quite right.
Read more

Comments (1) | Posted in Deep Thoughts, From the Workbench, Horn Tooting by Brian Forth


Oct. 27, 2006 at 11:25am

MS SQL Server 2005 text and ntext

text, ntext, and image data types have been deprecated

How I discovered that text, ntext, and image data types have been deprecated and replaced by varchar(max), ntext(max), and varbinary(max).

Recently, I needed to perform a query to update a number of links for the Pierce Count Library website. I thought I could use a simple REPLACE() string function, unfortunately, this turned out not to be the case. In order to update text and ntext datatypes using a query you're limited to a few functions, in my case I would be forced to use SUBSTRING() or UPDATETEXT().

Read more

Comments (1) | Posted in ASP.NET 2.0, Coding Techniques, From the Workbench, MS SQL Server by Ken Foubert


Oct. 17, 2006 at 11:33am

Smart Keyword Searching

Earlier this week the brand new Pierce County Library website officially launched. It was a pretty complex build that took a lot of effort between ourselves and the library's staff to make sure that everything worked right for the site's users. One of the more important features on any website with a large amount of content is a solid search function, and this site was no different. With over 300 pages (and still growing), a user could easily have some difficulty tracking down the information that they are looking for. So what can you do to make finding information easier? Read more

Comments (2) | Posted in Coding Techniques, From the Workbench by Mike Ash


Oct. 12, 2006 at 11:13pm

Using What We Build

AKA Avoiding Lines at the Health Department

It's not often that I use the stuff we build. It's not that I don't support the businesses we do business with, it's more that I spend so much time online thinking of how we build things for our customers that I don't generally get a chance to actually use the websites we build in the way a customer would.
Read more

Comments (0) | Posted in From the Workbench by Brian Forth