PHP / Mysql handle query errors
<p>How to handle errors in mysql queries. Suppose I have 2 insert queries (two different tables), first one executes successfully and if second one fails for some reason then how do I undo the insert/update that happened in my first one? Please provide some suggestions as Im beginner in php.</p>