i want to know what happens if there is a Insertion query in two function running in parallel or if query is inside a foreach loop..

> one more thing is my table has a AUTO INC field, so if two insertion query runs on same table at the same time , then what happens ? will it give error?
how to avoid any errors and do dis successfully?