Here's what I would do in this situation:
It's the old "Divide and Conquer" concept. Us programmers do this most the time - and when we don't do it (because we can't be bothered), the problem usually takes 5 times longer to solve.
- Create a new PHP script.
- Add the code that writes something to the database each time the script is run.
- Run the script from my browser.
- Check that the database was written to.
- If not, debug this script until it works.
- Run the script many times to confirm that it writes to the DB each time I open it in my browser.
- Copy the script to the Thank You page script.
- Re-test using the Thank You page directly (if possible).
- Re-test using the complete form process.
It seems like a bit of effort to go to, but it really is the best way to diagnose this type of problem.