jquery .min. js ошибка 500 внутренняя таблица данных сервера - PullRequest
0 голосов
/ 16 июня 2020

Я работаю на веб-странице с плагином DataTable, jQuery, AJAX, mySQL ... У меня забавная ошибка, и все, что я красный, мне не помогает.

Я протестировал мою страницу с помощью Xampp, и все работает нормально. Когда я загружаю его на сервер, он дает мне внутреннюю ошибку сервера 500, и я не понимаю, что не так.

Сначала у меня нормально работает логин. Затем у меня есть это html:

<?php 
    ob_start();
    if (session_status() == PHP_SESSION_NONE) 
      session_start();

    if (!(isset($_SESSION['type'])) or ($_SESSION['type'] == "DATA ADMINISTRATOR")) 
      header("Location: ./index.php");

?>   
<html>
    <head>
        <title>Customer</title>
<link rel="stylesheet" type="text/css" href="Themes/style.css">

        <script src="./DataTables/js/jquery.min.js"></script>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
        <script src="./DataTables/js/jquery.dataTables.min.js"></script>
        <script src="./DataTables/js/dataTables.bootstrap.min.js"></script>     
        <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />
        <script src="./DataTables/js/bootstrap.min.js"></script>
        <style>
            body
            {
                margin:0;
                padding:0;
                background-color:#f1f1f1;
            }
            .box
            {
                width:1270px;
                padding:20px;
                background-color:#fff;
                border:1px solid #ccc;
                border-radius:5px;
                margin-top:25px;
            }
        </style>
    </head>
    <header>
    <nav class="navigation-bar">
        <img class="logo" src='images/logo.png' />
    </nav>
    <nav class="navigation-menu" style=" width: 100%;height: 60px;background-color: #15937B;">
        <ul class="lista">
            <?php include "menu_others.php"; ?>
        </ul>
    </nav>
</header>
    <body>
        <div class="container box">
            <h3 align="center" style="height:10px;">Customer</h3>
            <br />
            <div class="table-responsive">
                <br />
                <div align="right">

                </div>
                <br />
                <table id="customer_data" class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th width="20%">Name</th>
                            <th width="20%">Contact No</th>
                            <th width="20%">eMail</th>
                            <th width="20%">Address</th>
                            <th width="10%">Country</th>
                        </tr>
                    </thead>
                </table>

            </div>
        </div>
    </body>
</html>

<script type="text/javascript" language="javascript" >
$(document).ready(function(){
    var dataTable = $('#customer_data').DataTable({
        "processing":false,
        "serverSide":true,
        "order":[],
        "ajax":{
            url:"customer_fetch.php",
            type:"POST"
        },
        "columnDefs":[
            {
                "targets":[],
                "orderable":false,
            },
        ],

    });
});
</script>
<?php
ob_end_flush();
?>

Это вызывает это php:

<?php
include('db.php');
include('customer_function.php');
$query = '';
$output = array();


$query .= "SELECT * FROM Customer, Country where country_id=country ";
if(isset($_POST["search"]["value"]))
{
    $query .= 'AND ( NAME LIKE "%'.$_POST["search"]["value"].'%" ';
    $query .= 'OR address LIKE "%'.$_POST["search"]["value"].'%" )';
}
if(isset($_POST["order"]))
{
    if ($_POST['order']['0']['column'] == 0)
        $query .= 'ORDER BY name ' .$_POST['order']['0']['dir'].' ';
    if ($_POST['order']['0']['column'] == 1)
        $query .= 'ORDER BY contact_no ' .$_POST['order']['0']['dir'].' ';
    if ($_POST['order']['0']['column'] == 2)
        $query .= 'ORDER BY email ' .$_POST['order']['0']['dir'].' ';
    if ($_POST['order']['0']['column'] == 3)
        $query .= 'ORDER BY address ' .$_POST['order']['0']['dir'].' ';
    if ($_POST['order']['0']['column'] == 4)
        $query .= 'ORDER BY country ' .$_POST['order']['0']['dir'].' ';
}
else
{
    $query .= 'ORDER BY customer_ID DESC ';
}
if($_POST["length"] != -1)
{
    $query .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length'];
}
error_log($query);
$statement = $connection->prepare($query);
error_log("prepared");
$statement->execute();
$result = $statement->fetchAll();
$data = array();
$filtered_rows = $statement->rowCount();
foreach($result as $row)
{
    $sub_array = array();
    $sub_array[] = $row[1];
    $sub_array[] = $row[2];
    $sub_array[] = $row[3];
    $sub_array[] = $row[4];
    $sub_array[] = $row[7];
    $sub_array[] = '<button type="button" name="update" id="'.$row[0].'" class="btn btn-warning btn-xs update">Update</button>';
    $sub_array[] = '<button type="button" name="delete" id="'.$row[0].'" class="btn btn-danger btn-xs delete">Delete</button>';
    $data[] = $sub_array;
}



$output = array(
    "draw"              =>  intval($_POST["draw"]),
    "recordsTotal"      =>  $filtered_rows,
    "recordsFiltered"   =>  get_total_all_records(),
    "data"              =>  $data
);



echo json_encode($output);
?>

Как видите, у меня есть error_log, чтобы показать мне запрос , этот работает нормально, после этого у меня появляется error_log после оператора подготовки, это не работает, поэтому похоже, что ошибка возникает, когда я выполняю оператор подготовки, я не знаю почему.

...