
Controllerlerim hata veriyor hat ayıklama açtığım zaman, get_result() yerine bind_result() fetch() kullanıyorum bu sefer kodlar çakışıyor. Bunun çözümünü bilen varmı veya yardımcı olabilecek biri?
Aşağıda kodum bulunmaktadır, değerli fikirlerinizi okuyacağım
<?php
session_start();
// Hata ayıklama için hata raporlama etkinleştirildi
ini_set('display_errors', 1);
error_reporting(E_ALL);
$host = 'localhost';
$user = '';
$pass = '';
$db = '';
$mysqli = new mysqli($host, $user, $pass, $db);
// Bağlantıyı kontrol et
if ($mysqli->connect_error) {
die("Veritabanı bağlantı hatası: " . $mysqli->connect_error);
}
// Kullanıcı giriş kontrolü
$uye_id = isset($_SESSION['uye_id']) ? $_SESSION['uye_id'] : null;
if (!$uye_id) {
echo "Giriş yapmanız gerekiyor.";
exit();
}
// Bildirimleri al
$query = "SELECT * FROM bildirim WHERE uye_id = ?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("i", $uye_id);
$stmt->execute();
$notifications = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
// Modül durumunu al
$module_query = "SELECT modul_durum FROM moduller WHERE modul_kisaadi = 'pazar'";
$module_result = $mysqli->query($module_query);
$module_status = $module_result->fetch_assoc()['modul_durum'];
$mysqli->close();
?>
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bildirimler</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
#notificationMenu {
position: absolute;
top: 50px;
right: 0;
width: 250px;
max-height: 300px;
overflow-y: auto;
border: 1px solid #444;
background-color: #2c2f33;
color: #ffffff;
padding: 10px;
display: none;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
border-radius: 8px;
z-index: 1000;
}
.notification-item {
padding: 10px;
border-bottom: 1px solid #444;
}
.notification-item.unread {
background-color: #3b3f45;
font-weight: bold;
}
.notification-item a {
text-decoration: none;
color: #ffffff;
display: block;
}
.notification-item a:hover {
background-color: #50545a;
}
#notificationCount {
background-color: #ff3366;
color: #ffffff;
font-weight: bold;
border-radius: 50%;
padding: 2px 6px;
font-size: 12px;
}
</style>
</head>
<body>
<div class="col-xl-3 col-lg-5">
<div class="d-flex align-items-center <?php echo ($module_status == 'aktif') ? 'justify-content-between' : ''; ?> w-100" style="<?php echo ($module_status != 'aktif') ? 'justify-content: flex-end;' : ''; ?>">
<?php if ($module_status == 'aktif') { ?>
<a href="hesabim/ilan-ekle" class="btn bg-red r12 py-xl-2 py-1 d-flex align-items-center">
<span class="ti ti-wallet ti-30"></span> Satış Yap
</a>
<?php } ?>
</div>
</div>
<button class="btn position-relative" onclick="toggleNotifications()" id="notificationBtn" style="cursor: pointer;">
<i class="fas fa-bell fa-lg"></i>
<span id="notificationCount" class="badge bg-danger position-absolute top-0 start-100 translate-middle">
<?php echo count(array_filter($notifications, function($notification) { return $notification['bildirim_durum'] === 'okunmadı'; })); ?>
</span>
</button>
<div id="notificationMenu">
<h6>Bildirimler</h6>
<hr>
<?php if (empty($notifications)) { ?>
<p>Hiç bildiriminiz yok.</p>
<?php } else { ?>
<?php foreach ($notifications as $notification) { ?>
<div class="notification-item <?php echo ($notification['bildirim_durum'] === 'okunmadı') ? 'unread' : ''; ?>">
<a href="?mark_as_read=<?php echo $notification['b_id']; ?>">
<div>
<span><?php echo $notification['bildirim_aciklama']; ?></span>
<small class="text-muted"><?php echo date('d.m.Y H:i', strtotime($notification['tarih'])); ?></small>
</div>
</a>
</div>
<?php } ?>
<?php } ?>
</div>
<script>
function toggleNotifications() {
const notificationMenu = document.getElementById('notificationMenu');
notificationMenu.style.display = notificationMenu.style.display === 'none' || notificationMenu.style.display === '' ? 'block' : 'none';
}
document.addEventListener('click', function(event) {
const notificationBtn = document.getElementById('notificationBtn');
const notificationMenu = document.getElementById('notificationMenu');
if (!notificationBtn.contains(event.target) && !notificationMenu.contains(event.target)) {
notificationMenu.style.display = 'none';
}
});
</script>
</body>
</html>