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 = xxx@abc.com';

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 = xxx@abc.com');

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

What I really meant was:

  UPDATE users SET password = '123456', email = xxx@abc.com';

What a difference 3 characters can make.

No comments:

Post a Comment