Monday, June 18, 2007

MySQL error: Field doesn't have a default value

When inserting a new record with varchar or text field that is required and has no default value. This error will display for example:

error : Field 'description' doesn't have a default value

The possible reason is that sql-mode in my.ini is set to STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION.

Change the value to
sql-mode = ""

Update 2011/4/25:
Add Default value "" if possible to avoid changing mysql setting.

Wednesday, January 31, 2007

Print Button

You can easily add a print button or link to your web page. To add a button use the following code:


The button looks like this:

To add a link you code it like this:
print

The link looks like this: print

You can also easily control what parts of your page print out by adding a special stylesheet that will be used for printing to the head section of your page like this:
<link rel="stylesheet" href="print.css"
type="text/css" media="print" />

The print.css file should contain the following:
body {visibility:hidden;}
.print {visibility:visible;}

Now all you need to do is to assign class="print" to whatever parts of your web page that you want to have print out. Anything on the page not assigned to this class will not print.