hocam veritabanı bağlantısını atayım bakın bi

<?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=******', '*********, *********');
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // PDO hatalarını yönetmek için
} 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]); // Burada :id için bir değer sağlıyoruz
    $settingsprint = $settings->fetch(PDO::FETCH_ASSOC);
    
    if (!$settingsprint) {
        throw new Exception("Ayarlar bulunamadı."); // Ayarların bulunamaması durumunda bir hata fırlatıyoruz
    }
} 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ı."); // Motor ayarlarının bulunamaması durumunda bir hata fırlatıyoruz
    }
} 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ı."); // Widget ayarlarının bulunamaması durumunda bir hata fırlatıyoruz
    }
} 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ı."); // WhatsApp bilgilerinin bulunamaması durumunda bir hata fırlatıyoruz
    }
} catch (PDOException $e) {
    echo "WhatsApp bilgileri yüklenemedi.";
    error_log("WhatsApp verisi çekilirken hata oluştu: " . $e->getMessage());
} catch (Exception $e) {
    echo $e->getMessage();
}
?>