I'm developing an app using CakePHP and have encountered a strange problem: When I POST data to a particular method I get a 0 byte response and a simple 404 error in the access log.

psycho953.psych.susx.ac.uk - - [11/Oct/2011:10:17:43 +0100] "GET /research/ssd/aesthetics/participants/add HTTP/1.1" 200 3255 "-" "Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"
psycho953.psych.susx.ac.uk - - [11/Oct/2011:10:17:44 +0100] "POST /research/ssd/aesthetics/participants/add HTTP/1.1" 404 - "http://webvm.psych.sussex.ac.uk/research/ssd/aesthetics/participants/add" "Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"

POSTing to other forms works, whether or not they use CakePHP or just regular PHP.

I can't figure out how to work beyond the 0 byte response. My question isn't so much "Why isn't this working?" as "How can I find out what's not working?"

For the record, php.ini is set to display errors and succeeds in doing so for syntax errors etc.

  • What's error_log saying? – Alien Life Form Oct 11 '11 at 9:53
  • No entries to do with this. (i.e. I can explain all the other errors and the timestamps don't match) – Tom Wright Oct 11 '11 at 9:55
  • Bit out of my comfort zone here, but maybe you could try XDebug? – Bart De Vos Oct 11 '11 at 10:12
  • Thanks, but from the homepage I can't actually tell what it does. I guess it's something to do with debugging PHP, but beyond that I have no idea. – Tom Wright Oct 11 '11 at 10:48
  • So it may be some code that reacts on a POST, and falls flat on a GET (not uncommon these days). Some folks do that to (try to) thwart robots. – Alien Life Form Oct 11 '11 at 11:18

OK, so the problem was due to an error, but I never found out what the error was. I only solved this by trial and (ahem) error and I'd still like to know how I could have done this more methodically.

For anyone interested, the problem was something to do with a missing field that Cake expected. I had disabled an input field that was prepopulated with data from elsewhere. I didn't realise that disabling the input would stop it's value being submitted. My workaround is to include a hidden field.

Again though, I've no idea why these errors weren't displayed and I'm not sure why the only clue was a 404 in the access log. I'll leave this question unanswered for a few days in case anyone wants to suggest a reason for this.

UPDATE: Turns out that it's a security "feature" of CakePHP. My form had a disabled input, which meant that the hash of field names that Cake passes with the form didn't match what it got back (disabled inputs don't get POSTED).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.