prepare("SELECT * FROM `category` WHERE slug = :slug"); $stmt->execute(['slug' => $slug]); $data = $stmt->fetch(PDO::FETCH_ASSOC); if ($data) { $cateId = $data['id']; $cateName = $data['name']; } } catch (PDOException $e) { // Handle potential database errors gracefully error_log("Database error: " . $e->getMessage()); header("Location: $base_url/404.htm"); exit; } } else { // 'slug' not set — redirect to 404 header("Location: $base_url/404.htm"); exit; } ?>