<?php
// Define the connection variable outside the function
function dynamicDbConnection($rjllearning_db_name){
    // echo $rjllearning_db_name;
    $servername_rjllearning = "localhost";
    $db_username_rjllearning = "rejoicebilldesk_education";
    $db_password_rjllearning = "rjlbilldesk22";
  
    //  // Initialize the connection variable
    // $conn_rjllearning_specific = null;
    try {
      
      $conn_rjllearning_specific = new PDO("mysql:host=$servername_rjllearning;dbname=$rjllearning_db_name;charset=utf8mb4", $db_username_rjllearning, $db_password_rjllearning);
      // set the PDO error mode to exception
      $conn_rjllearning_specific->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      //echo "Connected successfully";
    } catch(PDOException $e) {
      echo "Connection failed: " . $e->getMessage();
    }
    
   
    return $conn_rjllearning_specific;   

}

