title: SQL failing in one page on some machines
body: <p>Edit: Forgot to mention none of the SQL works at all when it fails.</p>
  
  <p>I seriously need help figuring this out. It has been about a month since the issue has arrived. I have rewrote the page a couple times and have tried removing some unneeded items in case it was a speed issue (had sidebar that auto scrolled and loaded in two social media widgets which was kinda slow on bad internet) and so far nothing. I really do not know why this happens at all.</p>
  
  <p>Here is the kicker. It only happens to random people. Never breaks for me but breaks nearly every time for a customer on certain pc's. Another issue that person is running into is the cart cookie won't clear for that person either(just them).</p>
  
  <p>I am Using Auth.net's DPM method which takes them offsite momentarily then to my Order_receipt page(the one in question). When arriving at that page you are given 2 $_GET properties example (order_receipt.php?response_code=1&amp;transaction_id=136434353) which is coming in properly even when it fails.</p>
  
  <p>Customer that has issue is using win 10, and has tried it with both chrome and edge running kaspersky antivirus (no issues on my end from either browser)</p>
  
  <p>I'm going to include all code loaded and included in that page below, starting with the order_receipt itself.</p>
  
  <p>** = redacted info</p>
  
  <p>Order_receipt.php:</p>
  
  <pre><code>&lt;?php
  require_once 'system/init.php';
  include 'includes/head.php';
  include 'includes/navigation.php';
  include 'includes/headerpartial.php';
  
  ?&gt;
  
  &lt;div id="maincontent" class="col-md-12"&gt;
  
  &lt;?php
  ini_set('error_reporting', -1); ini_set('display_errors', 'on');
  
  ini_set('log_errors', 1);
  
  ini_set('error_log', 'system/error_logs.log');
  
  $error_code = uniqid(mt_rand(), true);
  
  
  
  
  if ($_GET['response_code'] == 1)
  {
  
  
  
    $trans_id = $_GET['transaction_id'];
  
    if (isset($cart_id)){
  
  
    $db-&gt;query("UPDATE transactions SET charge_id = '$trans_id' WHERE cart_id = '$cart_id'");
  
  
  
  
    $tsql = $db-&gt;query("SELECT * FROM transactions WHERE cart_id = '$cart_id' ");
    $tran = mysqli_fetch_assoc($tsql);
  
  
  
  
  ?&gt;
  &lt;h1 id="reciept"&gt;Thank you for your support!&lt;/h1&gt;&lt;hr&gt;
  &lt;p id="reciept"&gt;
   On behalf of ** &lt;?=$tran['full_name']?&gt; we thank you for your purchase and hope you enjoy it!
  &lt;/p&gt;
  
  &lt;p id="reciept"&gt;
    You have selected &lt;b&gt;"&lt;?=$tran['pickup-location']?&gt;"&lt;/b&gt; as your pickup point.
  &lt;/p&gt;
  
  &lt;table id="nav-button" class="table table-bordered table-auto"&gt;
  
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;Transaction ID : &lt;?=$tran['charge_id']?&gt;&lt;/td&gt;
        &lt;/tr&gt;
  &lt;?php
  $a = 1;
  $it = 1;
  $string = $tran['items'];
  $itemar = explode(',', $string);
  $num = 1;
  
  $istr = $tran['inventory'];
  $stri = explode(',', $istr);
  
  
  if ($tran['status'] != "Complete") {
  
  
  foreach (array_slice($stri, $num) as $inve ){
  
  
    $exploded = explode('.', $inve);
  
    $itname = $exploded['0'];
    $itquan = $exploded['1'];
  
  
    $db-&gt;query("UPDATE products SET `quantity` = `quantity` - '$itquan' WHERE title = '$itname'");
  $db-&gt;query("UPDATE products SET `Sold` = `Sold` + '$itquan' WHERE title = '$itname'");
  
      $it++;
     }
     $compl = "Complete";
    $db-&gt;query("UPDATE transactions SET `status` = '$compl' WHERE cart_id = '$cart_id'");
  }
  
  
  foreach (array_slice($itemar, $num) as $itemr ){
  
  
  
    ?&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;?=$itemr?&gt;&lt;/td&gt;
        &lt;/tr&gt;
  
  
      &lt;?php
  
      $a++;
     } ?&gt;
  
     &lt;tr&gt;
       &lt;td&gt;
         Total: &lt;?=money($tran['grand_total']);?&gt;
       &lt;/td&gt;
     &lt;/tr&gt;
      &lt;/tbody&gt;
  
  &lt;/table&gt;
  
  
  
  
  &lt;?php
    $domain = '.'.$_SERVER['HTTP_HOST'];
  setcookie(CART_COOKIE,'',1,"/",$domain,false);
  
  
  }else{echo "Cart Id not Set";}
  
  
  
  }else
  {
  echo "Sorry, an error occurred: ".htmlentities($_GET['response_reason_text']);
  }?&gt;
  
  &lt;/div&gt;
  
  
  &lt;?php
  
  include 'includes/footer.php';
  ?&gt;
  </code></pre>
  
  <p>Init.php:</p>
  
  <pre><code>&lt;?php
  $db = mysqli_connect("**","**","**","**");
  if(mysqli_connect_errno()){
    echo 'Database connection failed with following errors: '. mysqli_connect_error();
    die();
  }
  session_start();
  require_once $_SERVER['DOCUMENT_ROOT'].'/config.php';
  require_once BASEURL.'helpers/helpers.php';
  
  $cart_id = '';
  if(isset($_COOKIE[CART_COOKIE])){
    $cart_id = sanitize($_COOKIE[CART_COOKIE]);
  }
  
  if (isset($_SESSION['LHUser'])) {
    $user_id = $_SESSION['LHUser'];
    $query = $db-&gt;query("SELECT * FROM users WHERE id = '$user_id'");
    $user_data = mysqli_fetch_assoc($query);
    $fn = explode(' ', $user_data['full_name']);
    $user_data['first'] = $fn[0];
    $user_data['last'] = $fn[1];
  }
  
  if (isset($_SESSION['success_flash'])) {
    echo '&lt;div class="bg-success"&gt;&lt;p class="text-success text-center"&gt;'.$_SESSION['success_flash'].'&lt;/p&gt;&lt;/div&gt;';
    unset($_SESSION['success_flash']);
  }
  
  
  if (isset($_SESSION['error_flash'])) {
    echo '&lt;div class="bg-danger"&gt;&lt;p class="text-danger text-center"&gt;'.$_SESSION['error_flash'].'&lt;/p&gt;&lt;/div&gt;';
    unset($_SESSION['error_flash']);
  }
  
  
  
   ?&gt;
  </code></pre>
  
  <p>config.php:</p>
  
  <pre><code>&lt;?php
  define('BASEURL', $_SERVER['DOCUMENT_ROOT'].'/');
  define('CART_COOKIE','Sd4CqdgRt6J3gd3F7');
  define('CART_COOKIE_EXPIRE', time() + (86400 * 30));
  
   ?&gt;
  </code></pre>
  
  <p>helpers.php:</p>
  
  <pre><code>&lt;?php
  ob_start();
  function display_errors($errors){
    $display = '&lt;ul class="bg-danger"&gt;';
    foreach ($errors as $error) {
      $display .= '&lt;li class="text-danger"&gt;'.$error.'&lt;/li&gt;';
    }
    $display .= '&lt;/ul&gt;';
    return $display;
  }
  
  function sanitize($dirty){
    return htmlentities($dirty,ENT_QUOTES,"UTF-8");
  
  }
  
  function money($number){
    return '$'.number_format($number,2);
  }
  
  function login($user_id){
    $_SESSION['LHUser'] = $user_id;
    global $db;
    $date = date("Y-m-d H:i:s");
    $db-&gt;query("UPDATE users SET last_login = '$date' WHERE id = '$user_id'");
    $_SESSION['success_flash'] = 'You are now logged in!';
    header('Location: index.php');
  }
  
  function is_logged_in(){
    if (isset($_SESSION['LHUser']) &amp;&amp; $_SESSION['LHUser'] &gt; 0) {
      return true;
    }
    return false;
  }
  
  
  function login_error_redirect($url = 'login.php'){
    $_SESSION['error_flash'] = 'You must be logged in to access that page';
    header('Location:'.$url);
  }
  
  function permission_error_redirect($url = 'login.php'){
    $_SESSION['error_flash'] = 'You don\'t have permission to access that page';
    header('Location:'.$url);
  }
  
  
  function has_permission($permission = 'admin'){
    global $user_data;
    $permissions = explode(',', $user_data['permissions']);
    if (in_array($permission,$permissions,true)) {
      return true;
    }
    return false;
  }
  
  
  function get_category($child_id){
    global $db;
    $id = sanitize($child_id);
    $sql = "SELECT p.id AS 'pid', p.category AS 'parent', c.id AS 'cid', c.category AS 'child'
            FROM categories c
            INNER JOIN categories p
            ON c.parent = p.id
            WHERE c.id = '$id'";
    $query = $db-&gt;query($sql);
    $category = mysqli_fetch_assoc($query);
    return $category;
  
  }
  </code></pre>
  
  <p>head.php:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;LettuceHeads&lt;/title&gt;
    &lt;link rel="stylesheet" href="css/bootstrap.min.css"&gt;
    &lt;link rel="stylesheet" href="css/main.css"&gt;
    &lt;link rel="icon" href="../images/header/logoicon.png"&gt;
    &lt;meta name="Viewport" content="width=device-width, initial-scale=1, user-scalable=no"&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script SRC="js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  
    &lt;div id="fb-root"&gt;&lt;/div&gt;
    &lt;script&gt;(function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;version=v2.6";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));&lt;/script&gt;
  </code></pre>
  
  <p>navigation.php:</p>
  
  <pre><code>&lt;?php
  $sql = "SELECT * FROM navigation ORDER BY `navigation`.`sort` ASC";
  $pquery = $db-&gt;query($sql);
   ?&gt;
  
  &lt;nav id="navbar" class="navbar navbar-default navbar-fixed-top" role="navigation"&gt;
   &lt;div id="navtext" class="containter"&gt;
     &lt;a id="navborder" href="index.php" class="navbar-brand"&gt;**&lt;/a&gt;
    &lt;ul class="nav navbar-nav"&gt;
      &lt;?php while($parent = mysqli_fetch_assoc($pquery)) : ?&gt;
      &lt;li id="navborder"&gt;&lt;a href="&lt;?=$parent['url'];?&gt;"&gt;&lt;?=$parent['name'];?&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;?php endwhile; ?&gt;
  
      &lt;/li&gt;
  
    &lt;/ul&gt;
    &lt;ul  id="navright" class="nav navbar-nav navbar-right" &gt;
  
      &lt;li id="navborder2"&gt;&lt;a href="cart.php"&gt;&lt;span class = "glyphicon glyphicon-shopping-cart"&gt;&lt;/span&gt; My Cart&lt;/a&gt;&lt;/li&gt;
    &lt;?php  if(has_permission('admin')): ?&gt;
        &lt;li id="navborder"&gt;&lt;a href="admin/index.php"&gt;Staff&lt;/a&gt;&lt;/li&gt;
    &lt;?php endif; ?&gt;
  &lt;/ul&gt;
  
   &lt;/div&gt;
  &lt;/nav&gt;
  </code></pre>
  
  <p>headerpartial.php:</p>
  
  <pre><code>&lt;div id="partialHeaderWrapper"&gt;
    &lt;div id="partialbackitem"&gt;&lt;/div&gt;
    &lt;div id="partiallogotext"&gt;&lt;/div&gt;
    &lt;div id="partialfore-item"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="container-fluid"&gt;
  </code></pre>
  
  <p>footer.php:</p>