If i run the function, I get an internal server error.
Anyone know how to fix?
I want to make that if you press a button it changes from class, and also changes it in the database.
<?php
include_once("../../inc/database.php");
$id = $db->real_escape_string($_GET['id']);
$GetCurrent = $db->query("SELECT * FROM mailbox WHERE id=".$id);
$FetchCurrent = $GetCurrent->fetch_assoc();
if ($FetchCurrent['pinned'] == '0') [
$query1 = $db->query("UPDATE mailbox SET pinned='1' WHERE id=".$id);
} else {
$query2 = $db->query("UPDATE mailbox SET pinned='0' WHERE id=".$id);
}
?>
<script>
function FlagMail(id){
$.ajax({
type: "GET",
url: "pages/run/mail-flag.php",
data: {id: id},
cache: false,
success: function(result){
var element = document.getElementById(id);
element.classList.toggle("fa-flag-o");
element.classList.toggle("fa-flag");
},
error: function(jqXHR, textStatus, errorThrown){
alert(errorThrown);
}
});
};
</script>
I expect the output of the class changing, but I get the error.