This item is from the Yet Another Enhanced IDE/Fast-ATA/ATA-2 FAQ, by John Wehman and Peter den Haan with numerous contributions by others. (v1.92).
Less than 18 inches. In some cases, the limit is no more than 7 inches.
The cable is a pretty weak link in the whole ATA-2 interface. For the fast transfer speeds used in 'EIDE' systems, there aren't enough ground signals; the cable is unterminated and unshielded. Noise is a real problem. All of this applies to ATA-2 (EIDE) systems more than Ultra-ATA systems, since the latter use checksums to ensure data integrity.
For those reasons, you should take the 18" limit specified by the ATA(-2) standard pretty seriously if you want to avoid data corruption and system hangs. Even worse, some dual-channel 'EIDE' interfaces such as CMD640x based ones have a peculiar design employing only a single buffer for both cables. Most signals on the two cables are directly connected with each other: this means that electrically, the cable lengths add up. Take into account that the copper traces on the circuit board are often a couple of inches long as well and you're facing a maximum cable length of roughly 7" per cable if you want to remain within spec.
If you have difficulties fitting everything in with a standard length cable, consider adding a new plug to it or rolling a complete cable yourself. It's not hard to do, or to track down a friend willing to do it, and you can buy the parts in all electronic parts stores. Do use quality parts, work carefully, and watch that length.
Disregard the above at your own peril. Noise induced problems usually pop up sporadically, can be very hard to detect and even harder to track down. Not least because they may appear completely unrelated and involve devices other than the harddisk.