It happens. It's a very simple mistake; one careless moment and someone could be putting in the wrong fuel in the vehicle. The most important part is to know how to fix the problem without damaging your vehicle any further.
Mixing up diesel and gas
With the different types of nozzles to prevent this kind of complication, it is pretty hard to make the mistake. But nevertheless, it still happens. The most important thing to do is to stop driving the car immediately. Turn off the engine and park it somewhere safe if possible, if you can't move it, just leave it. The whole point of this is to prevent any of the gas or diesel from entering the engine. The difference between the two engines is significant based on the properties of the fuel, for example gas combusts at a lower temperature and diesel serves not only as a fuel but also lubricant as well. If you know how to work on your car, you would want to drain and clean the tank, fuel lines, fuel rails and injectors. If you don't know how, a mechanic can do that for you easily, though the cost could be significant, ranging from $500-$1000 plus the tow. Then again, if you don't fix this mistake, your engine is as good done and you're looking at replacing that which makes the $500-$1000 seem like pocket change.
Using the wrong grade of gas
Firstly you would notice the check engine light go off. But understand it isn't a big deal if it happens once or twice. There is no immediate danger to your engine that will shut off your engine. Just fill up the tank with the grade it is supposed to take and it will eventually filter itself out. Common misconception is that if you fill your vehicle with premium that doesn't need it; you will get better performance out of it. That is false, the onboard engine computer will adjust the timing to compensate for the increased octane levels and you will feel absolutely no benefit. This is the same for the other way, although long term of using a lower grade of fuel for a premium engine would result in a spark knock which is described as a sort of high-pitched pinging or rattling noise. Long term damage from spark knock will result in damage to the vehicle.