Just an idea: may it still be an DB issue, not necessarily an environmental one ?
Is it possible that it is just 'too early' when you're making the SELECT, and that all goes well if you sleep() a while before that ?
I suspect that it might be possible that the problem is due to MySQL being late for some reason to let you see the just inserted/updated value.
Hope that helps.