title: MYSQL table locking with PHP
body: <p>I have mysql table <code>fg_stock</code>. Most of the time concurrent access is happening in this table. I used this code but it doesn't work:</p>
  
  <pre><code>&lt;?php
      mysql_query("LOCK TABLES fg_stock READ");
  
      $select=mysql_query("SELECT stock FROM fg_stock WHERE Item='$item'");
  
      while($res=mysql_fetch_array($select))
      {
          $stock=$res['stock'];
          $close_stock=$stock+$qty_in;
          $update=mysql_query("UPDATE  fg_stock SET stock='$close_stock' WHERE Item='$item' LIMIT 1");
      }
  
      mysql_query("UNLOCK TABLES");    
  ?&gt;
  </code></pre>
  
  <p>Is this okay?</p>