Year, make, model and engine would help but, a bad timing belt or a bad fuel pump could do that.
car starts but shut off while driving
Possible a bad or corroded ground cable .
I am no mechanic, but I had the same problem on my 95 Ford Taurus SHO. My car would just shut down while I was driving and turn on for awhile after it shut off. After looking around, I found out it was the crankshaft positioning sensor. I changed it out, and that fixed the problem. I suggest to look online taking to consideration your make and model of your vehicle.
yep... especially if the alternator is bad too
fuel pump
A lot of possible causes, I recommend a careful investigation.
Had to disconnet my radio it was shorting out the engine.
The mass air sensor sometimes would cause this problem
toyota mr 2
Faulty ignition wires, distributor cap and rotor could be to blame.
Yes! I got a 1994 MX6 and it would shut down while driving when your oil is low.
If it won't crank, which is probably what you really have going on, it means your battery went bad while you were driving.