title: SQL is only executing when one of the values is <= 4
body: <p>I'm trying to input orders into a MySQL database. It adds one record per order in an order table, then loops through all the items in the basket. It then selects information on each item, cahnges the commited stock for that item and then adds the information to an ordered_products table. This is where the problem lies. When executing the SQL through PHP it does not add to ordered_products table, unless the product_id is less than or equal to 4. This is not the case if I execute the SQL from phpMyAdmin. Below is the PHP.</p>
  
  <pre><code>$error = false;
  for ($i = 0; $i &lt; count($basket); $i++) {
          $productid = $basket[$i]['id'];
          $quantity = $basket[$i]['quantity'];
          $postage = $basket[$i]['postage'];
          $stmt-&gt;prepare("SELECT bodywork, wheels, seat, mechanical, batteries, `range`, `keys`, charger, serial_number FROM products WHERE product_id = ?");
          $stmt-&gt;bind_param('i', $productid);
          $stmt-&gt;execute();
          $stmt-&gt;bind_result($bodywork, $wheels, $seat, $mechanical, $batteries, $range, $keys, $charger, $serialnumber);
          $stmt-&gt;fetch();
          echo 'Product id = ' . $productid . '&lt;br /&gt;';
          $stmt-&gt;prepare("INSERT INTO ordered_products (order_id, product_id, quantity, postage, bodywork, wheels, seat, mechanical, batteries, `range`, `keys`, charger, serial_number) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
          $stmt-&gt;bind_param('iiiisssssiiis', $orderid, $productid, $quantity, $postage, $bodywork, $wheels, $seat, $mechanical, $batteries, $range, $keys, $charger, $serialnumber);
          $stmt-&gt;execute();
          $stmt-&gt;prepare("UPDATE products SET committed_stock = committed_stock + ? WHERE product_id = ?");
          $stmt-&gt;bind_param('ii', $quantity, $productid);
          $stmt-&gt;execute();
      if ($stmt-&gt;error) {
          echo 'An error occured, please try again. error = ' . $stmt-&gt;error;
          $error = true;
      } 
  }
  $stmt-&gt;close();
  $db-&gt;close();
  if (!$error) {
      //unset($_SESSION['basket']);
      echo 'Your order has been completed, thank you!';
  }
  </code></pre>
  
  <p>I hope I have provided enough information here. Because I am able to input values more than 4 when doing it directly, I have rules out a database-configuration error (I hope that's correct!).</p>