Occam's Razor applied to the jungle of debugging.
The question “why does my code not work?” is far too often accompanied by either too little or too much information. Neither facilitates good answers. Getting the amount of information right should be easy, but apparently isn't. This little flowchart might help.
The process of reducing the size of code necessary to reproduce the problem should result in you finding the problem yourself ~80% of the time – it is a highly educational process.
Usually programming errors can be reproduced in no more than one screenful of code, and quite often less. Exceptions to this are Heisenbugs (memory corruptions and threading errors), which are notoriously difficult to reproduce outside their natural habitat.