I don't see the 'where' condition changing in the loop. Each time you do "WHERE column = 'something'" it will match and replace ALL the rows, overwriting the ID from each previous update.
UPDATE:
Some of us wrote similar responses at the same time. I should have hit 'refresh' one more time before 'add'
For what it's worth, if this is a one-time fix to get sequential ids on a table, you can do that with straight mysql:
mysql> select * from foo;
+------+------+
| id | name |
+------+------+
| 0 | aaa |
| 0 | bbb |
| 0 | ccc |
| 0 | ddd |
+------+------+
4 rows in set (0.00 sec)
mysql> set @ct=0;
Query OK, 0 rows affected (0.00 sec)
mysql> update foo set id=(@ct:=@ct+1);
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> select * from foo;
+------+------+
| id | name |
+------+------+
| 1 | aaa |
| 2 | bbb |
| 3 | ccc |
| 4 | ddd |
+------+------+
4 rows in set (0.00 sec)
Use an 'order by' if you like, for instance:
mysql> update foo set id=(@ct:=@ct+1) order by name