Check Slash on Database Input

10th January 2008

If you are querying a database you should get into the habit of sanitising your input, even if it's not coming from users at the moment it might do in the future. SQL injection attacks are all too common and they can be easily prevented.

Getting A Random Row From A MS SQL Table

9th January 2008

To get a random row from a Microsoft SQL database you need to use the NEWID() function. This will generate a new random number for each row and order them by that new number. This is used in conjunction with the TOP clause to limit the amount of returned rows to one.

PHP Website Function Lookup

8th January 2008

Those of you who have coded in PHP must have looked at the PHP website at some point, even if it was just to down load the latest version, or to look up a function reference.

What most people don't realise is that there is a really easy way to go straight to the page that you want without having to mess around with the tetchy search engine on the PHP site.

PHP Array Mode Function

7th January 2008

The following mode function will return the most commonly occurring value from an array of values, also called the mode. If just the array is used then only the most commonly occurring value will be returned. The second parameter can be used to return an array containing the mode and the number of times that this value occurs in the array.

The PHP User On Linux

5th January 2008

Reading or writing a file using PHP is quite a common practice, but it can often fall cause programs to fall flat on their face if the proper user privileges are not in place. Although this is not a problem on Windows machines due to the lack of a proper security model, but on Linux machines you need to make sure your scripts can run with the correct permissions.

Postponing Code Running In JavaScript

4th January 2008

Creating user interfaces in JavaScript can sometimes lead to a problem, especially when the interface used AJAX to load data from the server. As many actions will be event driven by the user you can find that when a user triggers lots of events all at once the browser will send out lots of AJAX requests all at once. This can easily cause bandwidth issues but can also lead to the user getting confused while they patiently await the browser to settle down and let them get on with things.

For Loop Debugging In JavaScript

3rd January 2008

The for loop in JavaScript can be used to iterate through all items in an array or properties of an object. This makes looping through any object or array very easy. As in the following example that printing out all items in an array. Confine Draggable

2nd January 2008

Creating a new Draggable object with the framework is easy. You just create a new instance of the Draggable object with the element id to be made draggable as the first parameter and a set of options as the second.