I drove my car the other day and stopped it to for about an hour or so. When I was about to continue driving, it would start and run roughly for a short while and turn off. I attempted to start it up again but it did the same thing. It was running roughly while I kept my foot on the gas pedal so that it wouldn't shut off. However, after several seconds it just died out. After that, the car cranks fine but cannot be turned on at all. I suppose that the battery and the starter are working well. I had the hoses and wires checked. This issue happend suddenly and I've never had anything similar happen before. What could be the problem? Thanks.
When a fuel pump fails, it is known to happen randomly and can give the same symptoms you are describing. My first recommendation would be to have your fuel pressure checked by a certified professional to determine whether or not the fuel pressure is within the manufacturer’s specifications. If it is not, the fuel pump and fuel filter will likely need to be replaced in order to resolve this issue.
It is also possible that your ignition coil may have failed preventing any of the spark plugs from firing. I would recommend having your ignition system inspected as well. Ensure that your starting issue is diagnosed professionally as it relates to flammable substances and high voltage electricity. Once the source of the issue has been located, have the parts replaced as necessary in order to maintain the vehicle.