The best way to work with CFINPUT type=”checkbox” with MySQL

checkbox-1Since I began using CFML I’ve struggled with this problem every time I want to add a checkbox to a form that updates a database field.

The problem is that if the checkbox isn’t checked then no evidence of its existence is passed to the form’s action page. This causes a problem when updating a database field because you can’t rely on the FORM structure to provide a value of “no” or “off” that can be updated in your db field.
You therefore need to use something like this before your <cfupdate..>, <cfinsert…> or <cfquery…> tags.:

 <cfparam name="FORM.mycheckbox" default="off">

Similarly when populating a form containing a checkbox you need to use a plain <input type=”checkbox”> HTML tag instead of the CFINPUT version. This then allows you to insert <cfif> tag like so…

<input type="checkbox" name="myCheckbox" 
	<cfif #dbQuery.myCheckbox# eq 'on'> 

The db field must then be either a string-based data type or an enum type with ‘on’ and ‘off’ as its possible values.

Set XAMPP to automatically restart on an Ubuntu server

XAMPP, by default, does not automatically restart when the server is rebooted. To make this happen do the following :

cd /etc/rc2.d

place symbolic links to the XAMPP startup and kill processes in the rc2.d folder:

ln -s /opt/lampp/lampp S99lampp

ln -s /opt/lampp/lampp K01lampp

Now XAMPP should restart when the server is rebooted.

Set a static IP address on Ubuntu/XAMPP

Edit the following file:/etc/network/interfaces

and adjust it to your needs (in this example setup I will use the IP address

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface

auto lo
iface lo inet loopback

# This is a list of hotpluggable network interfaces
# They will be activated automatically by the hotplug subsystem.

mapping hotplug
script grep
map eth0

# The primary network interface

auto eth0
iface eth0 inet static