i would step through the code then, (or if you are not familiar with debuggers, echo on every line) to see if you get to the code you expect.