SQL在某些计算机上的一个页面中失败

时间:2016-06-03 16:23:02

标签: php sql

编辑:忘记在失败时根本没有提到任何SQL。

我非常需要帮助解决这个问题。这个问题已经到了一个月左右。我已经重写了几次页面,并试图删除一些不需要的项目,以防它是一个速度问题(有侧边栏自动滚动和加载在两个社交媒体小部件,这在互联网上有点慢),到目前为止没有。我真的不知道为什么会发生这种情况。

这是踢球者。它只发生在随机的人身上。从来没有打破我,但几乎每次都打破某个电脑的客户。这个人遇到的另一个问题是购物车cookie也不会为那个人清楚(只是他们)。

我正在使用Auth.net的DPM方法,它将它们暂时转移到我的Order_receipt页面(相关的那个)。到达该页面时,您将获得2 $ _GET属性示例(order_receipt.php?response_code = 1& transaction_id = 136434353),即使失败也会正常进入。

有问题的客户正在使用win 10,并且已经尝试使用chrome和edge运行kaspersky防病毒软件(我的任何浏览器都没有问题)

我将包含所有加载并包含在下面页面中的代码,从order_receipt本身开始。

** =编辑信息

Order_receipt.php:

<?php
require_once 'system/init.php';
include 'includes/head.php';
include 'includes/navigation.php';
include 'includes/headerpartial.php';

?>

<div id="maincontent" class="col-md-12">

<?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->query("UPDATE transactions SET charge_id = '$trans_id' WHERE cart_id = '$cart_id'");




  $tsql = $db->query("SELECT * FROM transactions WHERE cart_id = '$cart_id' ");
  $tran = mysqli_fetch_assoc($tsql);




?>
<h1 id="reciept">Thank you for your support!</h1><hr>
<p id="reciept">
 On behalf of ** <?=$tran['full_name']?> we thank you for your purchase and hope you enjoy it!
</p>

<p id="reciept">
  You have selected <b>"<?=$tran['pickup-location']?>"</b> as your pickup point.
</p>

<table id="nav-button" class="table table-bordered table-auto">

    <tbody>
      <tr>
        <td>Transaction ID : <?=$tran['charge_id']?></td>
      </tr>
<?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->query("UPDATE products SET `quantity` = `quantity` - '$itquan' WHERE title = '$itname'");
$db->query("UPDATE products SET `Sold` = `Sold` + '$itquan' WHERE title = '$itname'");

    $it++;
   }
   $compl = "Complete";
  $db->query("UPDATE transactions SET `status` = '$compl' WHERE cart_id = '$cart_id'");
}


foreach (array_slice($itemar, $num) as $itemr ){



  ?>
      <tr>
        <td><?=$itemr?></td>
      </tr>


    <?php

    $a++;
   } ?>

   <tr>
     <td>
       Total: <?=money($tran['grand_total']);?>
     </td>
   </tr>
    </tbody>

</table>




<?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']);
}?>

</div>


<?php

include 'includes/footer.php';
?>

的init.php:

<?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->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 '<div class="bg-success"><p class="text-success text-center">'.$_SESSION['success_flash'].'</p></div>';
  unset($_SESSION['success_flash']);
}


if (isset($_SESSION['error_flash'])) {
  echo '<div class="bg-danger"><p class="text-danger text-center">'.$_SESSION['error_flash'].'</p></div>';
  unset($_SESSION['error_flash']);
}



 ?>

的config.php:

<?php
define('BASEURL', $_SERVER['DOCUMENT_ROOT'].'/');
define('CART_COOKIE','Sd4CqdgRt6J3gd3F7');
define('CART_COOKIE_EXPIRE', time() + (86400 * 30));

 ?>

helpers.php:

<?php
ob_start();
function display_errors($errors){
  $display = '<ul class="bg-danger">';
  foreach ($errors as $error) {
    $display .= '<li class="text-danger">'.$error.'</li>';
  }
  $display .= '</ul>';
  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->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']) && $_SESSION['LHUser'] > 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->query($sql);
  $category = mysqli_fetch_assoc($query);
  return $category;

}

head.php:

<!DOCTYPE html>
<html>
<head>
  <title>LettuceHeads</title>
  <link rel="stylesheet" href="css/bootstrap.min.css">
  <link rel="stylesheet" href="css/main.css">
  <link rel="icon" href="../images/header/logoicon.png">
  <meta name="Viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  <script SRC="js/bootstrap.min.js"></script>
</head>
<body>


  <div id="fb-root"></div>
  <script>(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&version=v2.6";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));</script>

navigation.php:

<?php
$sql = "SELECT * FROM navigation ORDER BY `navigation`.`sort` ASC";
$pquery = $db->query($sql);
 ?>

<nav id="navbar" class="navbar navbar-default navbar-fixed-top" role="navigation">
 <div id="navtext" class="containter">
   <a id="navborder" href="index.php" class="navbar-brand">**</a>
  <ul class="nav navbar-nav">
    <?php while($parent = mysqli_fetch_assoc($pquery)) : ?>
    <li id="navborder"><a href="<?=$parent['url'];?>"><?=$parent['name'];?></a></li>
    <?php endwhile; ?>

    </li>

  </ul>
  <ul  id="navright" class="nav navbar-nav navbar-right" >

    <li id="navborder2"><a href="cart.php"><span class = "glyphicon glyphicon-shopping-cart"></span> My Cart</a></li>
  <?php  if(has_permission('admin')): ?>
      <li id="navborder"><a href="admin/index.php">Staff</a></li>
  <?php endif; ?>
</ul>

 </div>
</nav>

headerpartial.php:

<div id="partialHeaderWrapper">
  <div id="partialbackitem"></div>
  <div id="partiallogotext"></div>
  <div id="partialfore-item"></div>
</div>

<div class="container-fluid">

footer.php:

0 个答案:

没有答案