Sometimes squash, melons, or cucumbers will not bear any fruit at all, or what fruit they do have will rot when very small. Both problems are a question of pollination. If the female flowers are not present, you won't get anything. If females are present but not pollinated properly, the small fruit at the base will yellow and fall off a few days after the flower opens. You're not doing anything wrong, but you may be able to help.
Both male and female flowers (see below) are necessary in order to bear fruit. If only one type is present, or if they're not open at the same time, pollination won't happen. Several plants will begin the season with only one sex present, and may wait as long as a couple of weeks before producing the other; this is normal. It may be all-male or all-female, but eventually it will produce the other type and start putting out fruit. Pollinators, usually bees, will transfer pollen from the male to the female flowers. It takes up to 40 visits to a female flower to pollinate it sufficiently enough to bear fruit, and the blossom is only open for a day or less in most cases. Having a good bee population is essential. If there are not enough bees, it is possible to hand-pollinate the blossoms.
Additional causes of aborted fruit are excessively hot daytime temperatures, plant stress from improper watering, lack of nutrients, too much nitrogen, or the plant simply being too young to support fruit. In these cases, the plant may drop unopened female blossoms; correcting any stress, or waiting for the plant to mature, will stop the bud drop.