Config.php;
<?php
// Hata mesajlarını görüntüleme (yalnızca geliştirme sırasında etkinleştirin)
ini_set('display_errors', 1);
error_reporting(E_ALL);

try {
    // Veritabanı bağlantısını oluştur
    $db = new PDO('mysql:host=localhost;dbname=veritabani_adi', 'kullanici_adi', 'sifre');
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // PDO hatalarını yönetmek için
    $db->exec("SET NAMES 'utf8'"); // Türkçe karakter uyumu için karakter setini ayarlıyoruz
} catch (PDOException $e) {
    echo "Bağlantı başarısız. Lütfen daha sonra tekrar deneyin.";
    error_log("Veritabanı bağlantı hatası: " . $e->getMessage()); // Hataları loglamak
    exit;
}

// Genel site ayarlarını veritabanından çekme
try {
    $settings = $db->prepare("SELECT * FROM ayar WHERE ayar_id = :id");
    $settings->execute([':id' => 0]);
    $settingsprint = $settings->fetch(PDO::FETCH_ASSOC);
    
    if (!$settingsprint) {
        throw new Exception("Ayarlar bulunamadı.");
    }
} catch (PDOException $e) {
    echo "Ayarlar yüklenemedi.";
    error_log("Ayar verisi çekilirken hata oluştu: " . $e->getMessage());
} catch (Exception $e) {
    echo $e->getMessage();
}

// Sosyal medya bağlantılarını çekme
try {
    $social = $db->query("SELECT * FROM sosyal");
} catch (PDOException $e) {
    echo "Sosyal medya bilgileri yüklenemedi.";
    error_log("Sosyal medya verisi çekilirken hata oluştu: " . $e->getMessage());
}

// Motor ayarlarını çekme
try {
    $motor = $db->prepare("SELECT * FROM motor WHERE motor_id = :id");
    $motor->execute([':id' => 1]);
    $motorprint = $motor->fetch(PDO::FETCH_ASSOC);
    
    if (!$motorprint) {
        throw new Exception("Motor ayarları bulunamadı.");
    }
} catch (PDOException $e) {
    echo "Motor ayarları yüklenemedi.";
    error_log("Motor ayarları çekilirken hata oluştu: " . $e->getMessage());
} catch (Exception $e) {
    echo $e->getMessage();
}

// Widget ayarlarını çekme
try {
    $widgets = $db->prepare("SELECT * FROM widget WHERE widget_id = :id");
    $widgets->execute([':id' => 1]);
    $widgetprint = $widgets->fetch(PDO::FETCH_ASSOC);
    
    if (!$widgetprint) {
        throw new Exception("Widget ayarları bulunamadı.");
    }
} catch (PDOException $e) {
    echo "Widget ayarları yüklenemedi.";
    error_log("Widget verisi çekilirken hata oluştu: " . $e->getMessage());
} catch (Exception $e) {
    echo $e->getMessage();
}

// WhatsApp bilgilerini çekme
try {
    $whatsapp = $db->prepare("SELECT * FROM whatsapp WHERE whats_id = :id");
    $whatsapp->execute([':id' => 0]);
    $whatsappprint = $whatsapp->fetch(PDO::FETCH_ASSOC);
    
    if (!$whatsappprint) {
        throw new Exception("WhatsApp bilgileri bulunamadı.");
    }
} catch (PDOException $e) {
    echo "WhatsApp bilgileri yüklenemedi.";
    error_log("WhatsApp verisi çekilirken hata oluştu: " . $e->getMessage());
} catch (Exception $e) {
    echo $e->getMessage();
}
?>
Diğer Kod Satırı:
<?php
ob_start();
session_start();
date_default_timezone_set('Europe/Istanbul');

// Doğru dosya yolunu kontrol edin
include 'trex/controller/config.php';

// Genel site ayarlarını veritabanından çekme
try {
    $query = $db->prepare("SELECT * FROM ayar WHERE ayar_id = :id");
    $query->execute([':id' => 0]); // Parametre olarak 0 gönderiyoruz
    $settingsprint = $query->fetch(PDO::FETCH_ASSOC);

    if (!$settingsprint) {
        throw new Exception("Ayarlar bulunamadı."); // Ayarların bulunamaması durumunda hata fırlatıyoruz
    }
} catch (PDOException $e) {
    echo "Ayarlar yüklenemedi: " . $e->getMessage(); // Hata mesajını gösteriyoruz
    echo "<br>Sorgu: " . $query->queryString; // Hangi sorgunun çalıştığını gösteriyoruz
} catch (Exception $e) {
    echo $e->getMessage();
}
?>