我正在尝试进行aJax调用以显示故障单及其回复,aJax调用有效,但PHP页面没有,它给了我500错误,我真的不知道是什么错了,它甚至没有报告任何错误......
这是代码
<?php
include('../connect.php');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
function humanTiming ($time)
{
$time = time() - $time;
$time = ($time<1)? 1 : $time;
$tokens = array (
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($tokens as $unit => $text) {
if ($time < $unit) continue;
$numberOfUnits = floor($time / $unit);
return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
}
}
if(isset($_POST['id']) && !empty($_POST['id'])){
$tID = $_POST['id'];
$stmt = $dbh->prepare('SELECT ID, Author, Message, AuthorID, cTime FROM Tickets WHERE ID = :tid LIMIT 1');
$stmt->bindParam(':tid', $tID, PDO::PARAM_INT);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$auth = $result['Author'];
$msg = $result['Message'];
$authID = $result['AuthorID'];
$tTime = humanTiming($result['cTime']);
$stmt = null;
echo $msg;
echo '<hr />';
echo '<p class="align-right">- by ' . $auth . ', ' . $tTime . ' ago.';
echo '<br /> <br />';
$crg = $dbh->prepare('SELECT * FROM TicketReplies WHERE TicketID = :tid');
$crg->bindParam(':tid', $tID, PDO::PARAM_INT);
$crg->execute();
$count = $crg->rowCount();
if($count != 0){
echo '<h3><u>Replies</u></h3>';
while($row = $crg->fetch(PDO::FETCH_ASSOC)){
echo '<div class="alert bg-grey">';
echo '<span class="pull-left">by ' . $row['ReplyBy'] . ' - ' . humanTiming($row['cTime']) . ' ago';
if($row['sMember'] != 0){
echo '<span class="label bg-green pull-right">Staff Member</span>';
}
echo '<hr />';
echo $row['ReplyMsg'];
echo '<hr />';
echo '<br/>';
}
}
else {
echo '<p align="center">There are no replies.</p>';
}
}
?>
答案 0 :(得分:0)
我猜你正在编辑错误的剧本。重新打开你的编辑器
请将此标记为正确:)谢谢。哈哈