请大家帮我看下,下面这段代码,点击按钮发送的时候总是提示语法错误(接收到的数据不是有效的JSON格式),请问是什么情况
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once '../connections/games.php';
session_start();
$scriptDir = __DIR__;
$judge = basename($scriptDir);
$station = $_SESSION['station'];
$game = isset($_GET['game']) ? $_GET['game'] : null;
$m_name = isset($_GET['name']) ? $_GET['name'] : null;
$date = isset($_POST['date']) ? $_POST['date'] : null;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../../css/op.css">
<title>日程操作</title>
</head>
<body>
<br>
<?php
// 检查是否提交了表单
$statusesall = array("待开赛", "正在检录", "检录完成", "进行中", "已完赛"); // 要查询的状态列表
$inStatusesall = "'" . implode("', '", $statusesall) . "'";
if(!empty($date)) {
$sql = " SELECT * FROM m_dk_date
WHERE `date` =:date AND game =:game AND name =:name AND $judge = :judge AND station = :station AND now IN ($inStatusesall)
ORDER BY `id` ASC
";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':date', $date);
$stmt->bindParam(':game', $game);
$stmt->bindParam(':name', $m_name);
$stmt->bindParam(':judge', $username);
$stmt->bindParam(':station', $station);
$stmt->execute();
$order = $stmt->fetchAll(PDO::FETCH_ASSOC);
} else {
$sql = " SELECT * FROM m_dk_date
WHERE game =:game AND name =:name AND $judge = :judge AND station = :station AND now IN ($inStatusesall)
ORDER BY `id` ASC
";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':game', $game);
$stmt->bindParam(':name', $m_name);
$stmt->bindParam(':judge', $username);
$stmt->bindParam(':station', $station);
$stmt->execute();
$order = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
$statuses = array("待开赛", "正在检录", "检录完成", "进行中"); // 要查询的状态列表
$inStatuses = "'" . implode("', '", $statuses) . "'";
$sqlCount = " SELECT COUNT(*) AS total_now_count FROM m_dk_date
WHERE game =:game AND name =:name AND $judge = :judge AND station =:station AND now IN ($inStatuses) ";
$stmtCount = $pdo->prepare($sqlCount);
$stmtCount->bindParam(':game', $game);
$stmtCount->bindParam(':name', $m_name);
$stmtCount->bindParam(':judge', $username);
$stmtCount->bindParam(':station', $station);
$stmtCount->execute();
$countResult = $stmtCount->fetch(PDO::FETCH_ASSOC);
$totalnowCount = $countResult['total_now_count'];
?>
<div style="display:flex">
<form>
<button id="pzgg" name="pzgg" style="background:#ffba00">赛程 -> 配置到公告</button>
</form>
</div>
<a> 还有<?php echo $totalnowCount;?>项待完赛</a>
<div style="border-radius: 20px; background-color:#F8F8F8;">
<table style="font-family: inherit;color:#555">
<thead>
<tr align="center" style="font-weight:bold;font-size:10px;">
<th style="background:#3d77b3">顺序<br>Order</th>
<th style="background:#3d77b3">状态<br>State</th>
<th style="background:#3d77b3">单元<br>Unit</th>
<th style="background:#3d77b3">时间<br>Time</th>
<th style="background:#3d77b3">组别<br>Group</th>
<th style="background:#3d77b3">赛程<br>Schedule</th>
<th style="background:#3d77b3">主队<br>Team A</th>
<th style="background:#3d77b3">对阵<br>VS</th>
<th style="background:#3d77b3">客队<br>Team B</th>
<th style="background:#3d77b3">备注<br>Remark</th>
</tr>
</thead>
<tbody>
<?php
foreach ($order as $row):
?>
<tr style="font-weight:bold;font-size:10px;">
<td><?php echo htmlspecialchars($row['order']);?></td>
<td><?php echo htmlspecialchars($row['now']); ?></td>
<td><?php echo htmlspecialchars($row['apm']); ?></td>
<td><?php
$time = substr(htmlspecialchars($row['time']),0,5);
echo $time; ?></td>
<td>
<?php echo htmlspecialchars($row['group']); ?></td>
<td><?php echo htmlspecialchars($row['schedule']); ?></td>
<td style="display: flex;align-items: center;justify-content: right;"><?php
echo htmlspecialchars($row['team_a']);
$team_a = htmlspecialchars($row['team_a']);
$team_flag_a_Path = '../../image/d_logos/'.$m_name."/".$team_a.'.png';
if (file_exists($team_flag_a_Path)) {
echo '<img src="'.$team_flag_a_Path.'" height="32px">';
}
if (!empty($row['code_a'])){
echo '<span style="width:54px;height:30px;background:#3d77b3;border-radius: 15px;color:#fff;font-size:22px">'.htmlspecialchars($row['code_a'])."</span>";
}?>
</td>
<td style="align-items: center;">
<?php echo '<span style="width:32px;height:32px;background:#d10000;border-radius: 16px;color:#fff;font-size:22px">vs</span>';?>
</td>
<td style="display: flex;align-items: center;justify-content: left;">
<?php
if (!empty($row['code_b'])){
echo '<span style="width:54px;height:30px;background:#ffba00;border-radius: 15px;color:#fff;font-size:22px">'.htmlspecialchars($row['code_b'])."</span>";
}
$team_b = htmlspecialchars($row['team_b']);
$team_flag_b_Path = '../../image/d_logos/'.$m_name."/".$team_b.'.png';
if (file_exists($team_flag_b_Path)) {
echo '<img src="'.$team_flag_b_Path.'" height="32px">';
}
echo htmlspecialchars($row['team_b']);
?></td>
<td><?php echo htmlspecialchars($row['remark']); ?></td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
// 以下,将赛程的情况配置到结果中,用以公告查询
$(document).ready(function() {
$('#pzgg').click(function() {
var orderData = [];
var date = $('#date-select').val();
$('tbody tr').each(function() {
var rowData = {
date: date,
order: $(this).find('td:eq(0)').text(),
now: $(this).find('td:eq(1)').text(),
apm: $(this).find('td:eq(2)').text(),
group: $(this).find('td:eq(4)').text(),
schedule: $(this).find('td:eq(5)').text(),
code_a: $(this).find('td:eq(6) span').text(),
code_b: $(this).find('td:eq(8) span').text()
};
orderData.push(rowData);
});
var m_name = '<?php echo htmlspecialchars($m_name); ?>';
var game = '<?php echo htmlspecialchars($game); ?>';
$.ajax({
url: 'dd_result_into.php',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
data: orderData,
date: date,
m_name: m_name,
game: game
}),
dataType: 'text',
success: function(response) {
console.log('数据发送成功:', response);
// 处理响应
},
error: function(xhr, status, error) {
console.error('数据发送失败:', status, error, xhr.responseText);
// 根据需要处理错误
}
});
});
});
</script>
</html>