whenever i start the the car the first 3-4 times the engine turns off straight away. this happens at random times whether hot or cold. whats causing this?

2nd prob is after i park i hear metallic knocking/pinging noises coming from the car. why is that?

thanks,