Articles tagged with: Code
To quickly loop through a list node and set a rollover CSS value, use the following
// Set all LI of a node to rollover CSS
// Use two CSS class, e.g. item and itemover
function updateList(String nodename)
{
…
It is sometimes necessary to maintain the special characters in text, such as the apostrophe, speech marks, null character and backslash as these can be mis-interpreted by systems such as SQL if not modified appropriately. …
To set the focus of a HTML text box include this short piece of code in the <head> section
<script>function setfoc() { document.f1.KeyWords.focus(); }
In the example above f1 is the name of the form and KeyWords …
It is often useful to check that a given domain name or host is valid, this can be achieved using the checkdnserr() command, as in the following example:
$hostname = “www.domain.com.”;
$dnstype = “MX”;
$bValid = checkdnserr($hostname,$dnstype);
If using …
Quick routine to mix up the items in an array
public Object[] MixUpArray(Object inarray[])
{
// get the size of the array
int iSize = inarray.length;
// create an array the same size as the input array
…
This short routine shows how to ensure a selected item in a list is within bounds. If the list is empty the getSelectedIndex will return -1. The index starts at zero whilst size() will start …
Sample code to avoid SQL injections using mysql_real_escape_string (http://uk.php.net/mysql_real_escape_string) which converts special characters to escape sequences to ensure they are suitable for submission to SQL
$mySQL = “UPDATE address SET postcode=’.mysql_real_escape_string($postcode).’ WHERE id=’.mysql_real_escape_string ($account).’”;
$myResult = mysql_query($mySQL);
Essentially, require() and include() act in much the same way in that they both include the contents of another file – the only difference being that if include() fails then processing will continue (but produce a …

Jason Slater is an independent technologist and blogger.