query("SELECT * FROM live_top_ads ORDER BY RAND() LIMIT 1")->fetch(PDO::FETCH_ASSOC); // Fetch 2 random side ads $side_ads = $conn->query("SELECT * FROM live_side_ads ORDER BY RAND() LIMIT 2")->fetchAll(PDO::FETCH_ASSOC); } catch (Exception $e) { $error_message = "Failed to connect to the database: " . $e->getMessage(); } // Now Showing logic date_default_timezone_set("Asia/Colombo"); $currentDay = date('l'); $currentTime = date('H:i:s'); try { if (isset($conn)) { $now_stmt = $conn->prepare(" SELECT * FROM tv_schedule WHERE day = :day AND time <= :time ORDER BY time DESC LIMIT 1 "); $now_stmt->execute([':day'=>$currentDay, ':time'=>$currentTime]); $now_program = $now_stmt->fetch(PDO::FETCH_ASSOC); } } catch (Exception $e) { if (!isset($error_message)) $error_message = "DB Error: "."Failed to connect to the database"; } ?> Live TV Player