MySQL Query Failed in PHP but Success through MYSQL Client
<p>Anyone, please take a look at my code in PHP, why is it failed.</p>

<p><strong>CODE</strong></p>

<pre><code>$mysqli-&gt;query('LOCK TABLES fg_out_body READ,fg_out_head READ');
$sqlCheck = "SELECT * FROM fg_out_body WHERE part_no='$partno' AND lot_no='$lotno'";
$resultCheck = $mysqli-&gt;query($sqlCheck);
if ($resultCheck-&gt;num_rows &gt; 0) {
  echo 'record exists';
} else {
    $sqlHead = "INSERT IGNORE INTO fg_out_head(fg_doc_no,`type`,`date`,acc_no,
                                           prod_loc,destination,user_id) 
                                    VALUES('$docno','$tipe','$tanggal','$customer',
                                           '$prodloc','$destination','$userid')";
    if ($mysqli-&gt;query($sqlHead)) {
        echo "success";
    }else{
        echo "failed";
    }
}
</code></pre>

<p>But if i paste the query directly to mysql, it can run without error.</p>

<p>CODE</p>

<pre><code>INSERT IGNORE INTO 
 fg_out_head(fg_doc_no,`type`,`date`,acc_no,prod_loc,destination,user_id) 
VALUES('FVOT-00001','VARIANCE OUT','2016-04-27','','','Other','')
</code></pre>

<p>This message from the console</p>

<p><code>Table 'fg_out_head' was locked with a READ lock and can't be updated</code></p>