The cum hoc fallacy is committed when it is assumed that because two things occur together, they must be causally related. This, however, does not follow; correlation is possible without causation. This fallacy is closely related to the post hoc fallacy.
Example
As the graph below (taken from the Church of the Flying Spaghetti Monster website) shows, two things have happened since the early 19th-century: one is that the number of pirates has declined, the other is that global average temperatures have risen.
If correlation implied causation, we would be able to infer a connection between these two events. It is not the case, however, that global warming is an effect of the decline in piracy. Neither is the decline in piracy the result of increasing temperatures. Mere correlation does not imply a causal connection.
Real-World Example
Nestle, the makers of the breakfast cereal Shredded Wheat, once ran an advertising campaign in which the key phrase was this: “People who eat Shredded Wheat tend to have healthy hearts.” This is very carefully phrased. It does not explicitly state that there is any causal connection between eating Shredded Wheat and having a healthy heart, but it invites viewers of the advertisements to make the connection; the implication is there. Whether or not there is any such connection, the mere fact that the two things are correlated does not prove that there is such a connection. In tempting viewers to infer that eating Shredded Wheat is good for your heart, Nestle are tempting viewers to commit a fallacy.