I am not sure if I understand correctly lock tables statement. I hope somebody can explain this situation:

I would like to lock table photos, so nobody can insert new photo while user A is inserting photo and getting inserted id.

photos
photoId | photo | userId

PHP Code:
$db->query("LOCK TABLES photos write");
$db->query("INSERT INTO photos (userId,photo) VALUE (1,'$photo')");
$photoId=mysql_insert_id();
$db->query("UNLOCK TABLES"); 
I tried this in localhost. First I removed the last line ($db->query("UNLOCK TABLES")), so when a user A open the script, table stays locked. I opened script test.php in firefox and then the same script as user B in chrome. As user B I didn't get any error and new photo has been inserted. Why that? Isn't supossed to get error in this case as table is still locked?

tnx!