Tuesday, February 27. 2007
MySQL sql-mode breaks PHP application
I'm looking for an open source implementation of a stable, easy customizable, well supported ecommerce application like OsCommerce or CubeCart. To be able to try one or two of these apps for myself I installed a complete LAMP stack on a virtual windows XP image a while back.
I used MySQL 5 for that was the latest version at the time. Not aware of some of the changes in the default configuration, every ecommerce package that I tried to run gave me an error message at the point I tried to add something to the database. Be it a new category or item. OsCommerce as well as CubeCart could not insert anything into the database and gave me a message similar to this one:
1366: Incorrect decimal value: '' for column 'per_ship' at row 1
QUERY = INSERT INTO store_CubeCart_category (`cat_name`, `cat_father_id`, `cat_image`, `per_ship`, `item_ship`, `item_int_ship`, `per_int_ship`) VALUES ('test', '1', '', '', '', '', '')
The cause of this error can be traced back to the configuration of MySQL 5 and a new 'feature' called STRICT_TRANS_TABLES that is turned on by default. At least for the windows version of MySQL. The following line in the configuration file my.ini was causing these PHP applications to fail:
# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
The MySQL documentation gives the following information about STRICT_TRANS_TABLES: If a value could not be inserted as given into a transactional table, abort the statement. For a non-transactional table, abort the statement if the value occurs in a single-row statement or the first row of a multiple-row statement. More detail is given later in this section. (Implemented in MySQL 5.0.2)
The solution to the errors is simple. Remove the STRICT_TRANS_TABLES from the sql-mode setting and everything runs smoothly.
Saturday, February 24. 2007
Beat them to it
Yesterday I did a post about the Windows XP wallpaper 'Serenity' and how a man named nick tosches tried to find the place where the photo was shot.
Today I found out that the same story made it to a big Dutch news site webwereld.nl. I think it's fun that I beat them to it this time!
Friday, February 23. 2007
The origin of 'Autumn'
Every release of Windows comes with a stock of desktop wallpaper art. Usualy photographs of beautiful landscapes.
The latest Windows release Vista comes with a photo of a sand dune with small bushes and grass on it which I like very much and have currently installed as my active desktop wallpaper.
Have you ever wondered where these photographs where taken? If you knew, would you visit the place you look at on your computer screen every day? As it turns out there are people who can get quite obsessive about it.
Take the photo of the Windows XP desktop wallpaper named 'Serenity' (shown here). Someone by the name of Nick Tosches actually wrote an entertaining article about his obsession for this particular photo and how he tried to find the man responsible for it and the place it was shot.
CSS :hover for any element in Internet Explorer
Yes that's right! The :hover style normally only works with <a> tags in IE while it should work for any other element as well. Other browsers like FireFox did a better job supporting this but since the majority is using IE we're stuck with a broken :hover implementation.
There is a cure however. A pretty smart piece of javascript by Peter Nederlof fixes this particular problem very elegant. He created a behavior for IE which can read your stylesheets and attach onmouseover and onmouseout events to the HTML elements that needs them to enable the :hover effect.
To enable the :hover style for almost any element in IE, all you would have to do is to attach the behaviour the the body element in your stylesheet like this:
{
behavior: url(javascript/csshover.htc);
}
For a full explanation and the behavior code turn to Peter Nederlof's site: Whatever:hover
This is a real Gem!
Thursday, February 15. 2007
Put a Stop to Table Based Layout!
First let me explain what table based layout is all about. Before the era of Netscape and Internet explorer version 4 we already used tables to create complex layouts for our web sites. We use tables to create separate containers (cells) that allow us to place our content exactly where we want it. Best of all we could stretch these cells to fill up the available space so that everything is aligned nicely.
E.g. tables allow us to have a small column on the left with the site’s navigation links while the main content is in a second column taking up the rest of the screen. Perhaps you used to add a row above these two columns spanning them both to show the site’s title and a banner.
I do a lot of web applications which, basically, use this kind of layout. And I used to do this with tables, just the way as you are probably still doing, not realizing that there are better, more efficient, cleaner ways to do it. A friend opened my eyes a few years back and for that I am thankful. Now let me open your eyes so you can be thankful to me ![]()
