@ Twisty
У меня ошибка $ data = $ sql -> fetch_asso c ();
if (isset($_POST['addComment'])) {
$comment = $conn->real_escape_string($_POST['comment']);
$naslov = $conn->real_escape_string($_POST['naslov']);
$kategorija = $conn->real_escape_string($_POST['kategorija']);
$isReply = $conn->real_escape_string($_POST['isReply']);
$commentID = $conn->real_escape_string($_POST['commentID']);
if ($isReply == 'true') {
if (isset($_SESSION['doctorID'])) {
$conn->query("INSERT INTO replies (comment, commentID, doctorID, createdOn) VALUES ('$comment', '$commentID', '".$_SESSION['doctorID']."', NOW())");
$sql = $conn->query("SELECT replies.id, name, naslov, kategorija, comment, DATE_FORMAT(replies.createdOn, '%d-%m-%y') AS createdOn FROM replies INNER JOIN doctors ON replies.doctorID = doctors.id ORDER BY replies.id DESC LIMIT 1");
$data = $sql->fetch_assoc();
$str = 'true';
exit(KreirajPitanje($data, $str));
} else {
echo '<script>Swal.fire({
title: "Greška!",
text: "Niste doktor!",
icon: "error",
confirmButtonText: "U redu"
});</script>';
exit();
}
}
if ($isReply == 'false') {
if (isset($_SESSION['userID'])) {
$conn->query("INSERT INTO comments (userID, naslov, kategorija, comment, createdOn) VALUES ('".$_SESSION['userID']."','$naslov','$kategorija','$comment',NOW())");
$sql = $conn->query("SELECT comments.id, name, naslov, kategorija, comment, DATE_FORMAT(comments.createdOn, '%d-%m-%y') AS createdOn FROM comments INNER JOIN users ON comments.userID = users.id ORDER BY comments.id DESC LIMIT 1");
$data = $sql->fetch_assoc();
$str = 'false';
exit(KreirajPitanje($data, $str));
} else {
echo '<script>Swal.fire({
title: "Greška!",
text: "Niste se ulogovali/ne mozete to kao doktor!",
icon: "error",
confirmButtonText: "U redu"
});</script>';
exit();
}
}}