About Me

Mark Ferree

A web developer with a strong interest in design and open source.

I spend a lot of my time writing PHP and I have a passion for semantic HTML and anything related to Drupal.

From The Blog

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.