Theres a down side to using a php oriented solution, and it's that you can only assure this on a single machine. You can certainly lock it down to a single process in a critical region, but only on a single machine. If you were to have 2 frontend apache/php servers and one backend mysql server, this solution would fail. A MySQL transaction is by far the better solution..
Yet, imagining there is only one machine running this code, it's possible with either the solution Jon posted (using a file as a lock) or if you're on a linux/unix server you can also use IPC methods, and create a system V semaphore with length 1 (a mutex).
# in your scripts setup/init phase:
define('MUTEX_KEY', 123456); # the key to access you unique semaphore
sem_get( MUTEX_KEY, 1, 0666, 1 );
# later on, you reach the critical section:
# sem_acquire will block until the mutex has become availible
sem_acquire( ($resource = sem_get( MUTEX_KEY )) );
# queries here ...
sem_release( $resource );
# now that sem_release has been called, the next processes that was blocked
# on the sem_acquire call may enter the critical region
Although the file based solution is more portable (works on windows servers) the mutex/sem_* solution is much faster and safer (the auto_release, for example if an application for some reason crashes during the critical region wont block all further requests)
Cheers