November 2009

Be Careful with MySQL Field Names

MySQL Logo

Today's tip is going to be a quick one, but I wanted to share since the solution wasn't completely obvious to me for a while even though I've been using MySQL for several years now on a daily basis.

When naming your fields be sure you don't name them using language that MySQL might attempt to parse as a command. I was going along creating my database, and named a field 'primary' because that was what I'd called the value in the form, and it made sense in context. I then spent a good amount of time scratching my head wondering why all my values were saving in my update SQL I was sending unless this one was included. I realized the problem when I copy and pasted the SQL being run into PHPMyAdmin and saw that the line was breaking after it saw 'primary' in the command and realized my mistake.

Internet Explorer Doesn't Like Your Trailing Commas

Internet Explorer Icon

I just got bit by a strange bug that I haven't encountered before and wanted to share the 5 minute solution with everyone so they don't spend the hour I did trying to install Visual Web Developer Lite in a virtual machine to debug IE's Javascript wackiness.

Firefox could care less if you write your code like this: