Wednesday, March 26, 2008

Code Gotcha Of The Day

First time I've fallen for this one. I was sanitizing a production database for development use and ran the following query to reset everything:

  UPDATE users SET password = '123456' AND email =';

See the problem? Neither did I for a few seconds, and then realized that MySQL treated the above as:

 UPDATE users SET password = ('123456' AND email =');

So, I reset every users password to 0 and left e-mail alone.

What I really meant was:

  UPDATE users SET password = '123456', email =';

What a difference 3 characters can make.

No comments:

Post a Comment