prepare("SELECT COUNT(*) FROM subscriptions WHERE user_id = :userId"); $stmt->bindValue(':userId', $userId, SQLITE3_INTEGER); $result = $stmt->execute(); $row = $result->fetchArray(SQLITE3_NUM); $subscriptionCount = $row[0]; if ($subscriptionCount === 0) { header('Location: subscriptions.php'); exit; } }