"What you describe sounds like squash vine borer. This insect lays its eggs in the main stem at ground level. When the eggs hatch, the larvae tunnel into the stem, girdling and killing the plant. You can sometimes prevent the adult from laying eggs by wrapping the stem with aluminum foil. (You can also use preventative insecticide sprays. Bt is relatively nontoxic, but must be applied before the larvae tunnels into the stem.)
If infestation occurs, you can sometimes save the plant by slicing open the stem lengthwise, extracting the larva, and mounding soil up around the stem."