It looks like Ralph may be right. Either it just fell out or it snapped off inside. You should be able to just loosen the cap (the one with the ridges), push the top pipe back in, then retighten the cap.
From the photo it looks like the pipe is not actually PVC but rather the cheap, thinner, plastic do-it-yourself stuff. If for some reason you can't put the pipes back together as is, go to Home Depot or Lowes, in the section where you can find PVC, and you should be able to find bags of the cheap plastic fittings for sale. They come in a plastic bag with about 10 parts -- sort of a kit for doing a sink drain. PVC and the thinner plastic are not interchangeable.