It could also be something as minor as a loose air cleaner assembly. If you have a loose clamp on the air intake system,it will do the same thing. If you've got a stock air cleaner and just checked the filter and didn't get the housing on all the way,the car won't run. I had a 4.3 liter Caprice with a bad gas cap and the car did the same thing,start and shut right off.
You really need to provide more info about your car. Year,miles,any recent work done,is this car new to you. You get the idea.