title: MySQL Transaction giving error
body: <p>Been stuck on this for hours now, I am new to server development so please be easy on me.</p>
  
  <p>When I try running the code below I get the following SQL error: </p>
  
  <blockquote>
    <p>Error: </p>
  </blockquote>
  
  <pre><code>SET AUTOCOMMIT=0;
  START TRANSACTION;
  BEGIN;
  INSERT
       INTO  orders (firstname, lastname, spots, order_id)
      VALUES  ('NAME', 'NAME', 5, '20170718-FC5E8');
  INSERT
       INTO  orders_info (order_id, ip, user_agent)
      VALUES  ('20170718-FC5E8', '', 'browser');
  COMMIT;
  </code></pre>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near <code>'START TRANSACTION; BEGIN; INSERT INTO orders (firstname, lastname, spots, order_'</code> at line 1</p>
  </blockquote>
  
  <p>What I am trying to do is insert data into two different tables, which I am having big trouble with. I am trying to insert data into both orders and orders_info and for doing that I am using this query code:</p>
  
  <pre><code> $sql = "SET AUTOCOMMIT=0; START TRANSACTION; BEGIN; INSERT INTO orders (firstname, lastname, spots, order_id)
          VALUES ('$firstname_value', '$lastname_value', $spots_value, '$unique'); INSERT INTO orders_info (order_id, ip, user_agent)
          VALUES ('$unique', '$ip', 'browser'); COMMIT;";
  
          if ($conn-&gt;query($sql) === TRUE) {
              echo "Your order has been placed!" ."&lt;br&gt;&lt;br&gt;". "Firstname: {$firstname_value}" ."&lt;br&gt;". "Lastname: {$lastname_value}" ."&lt;br&gt;". "Spots: {$spots_value}";
              echo "&lt;br&gt;&lt;br&gt;" . "ORDER #: {$unique}";
          } else {
              echo "Error: " . $sql . "&lt;br&gt;" . $conn-&gt;error;
          }
  
          $conn-&gt;close();
  </code></pre>